ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:73957] [Ruby trunk Bug#12106] Behavior of double splatting of hashes with non symbol key is different according to splatted hash position
       [not found] <redmine.issue-12106.20160224042950@ruby-lang.org>
@ 2016-02-24  4:29 ` pablodherrero
  2016-02-24  4:33 ` [ruby-core:73958] " pablodherrero
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: pablodherrero @ 2016-02-24  4:29 UTC (permalink / raw)
  To: ruby-core

Issue #12106 has been reported by Pablo Herrero.

----------------------------------------
Bug #12106: Behavior of double splatting of hashes with non symbol key is different according to splatted hash position
https://bugs.ruby-lang.org/issues/12106

* Author: Pablo Herrero
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
When doing double splatting with hash with non symbols keys you get different behaviors according to the position of the hash been splatted:

```ruby
{a: 3, **{b: 1}, **{'b' => 1}}     # Works fine
{a: 3, **{1 => 1}, **{b: 1}}       # Works fine
{3 => 3, **{b: 1}, **{'b' => 1}}   # Works fine
{**{}, a: 3, **{b: 1}, **{1 => 1}} # Works fine

{**{b: 1}, a: 3, **{1 => 1}}       # TypeError: wrong argument type Fixnum (expected Symbol)
{**{'b' => 1}, **{c: 4}}           # TypeError: wrong argument type Fixnum (expected Symbol)
{**{c: 4}, **{'b' => 1}}           # TypeError: wrong argument type Fixnum (expected Symbol)
{**{c: 4}, a: 3, **{'b' => 1}}     # TypeError: wrong argument type Fixnum (expected Symbol)
```

Same thing happens when you double splat inside a message send:


```ruby
puts(a: 3, **{b: 1}, **{'b' => 1})     # Works fine
puts(a: 3, **{1 => 1}, **{b: 1})       # Works fine
puts(3 => 3, **{b: 1}, **{'b' => 1})   # Works fine
puts(**{}, a: 3, **{b: 1}, **{1 => 1}) # Works fine

puts(**{b: 1}, a: 3, **{1 => 1})       # TypeError: wrong argument type Fixnum (expected Symbol)
puts(**{'b' => 1}, **{c: 4})           # TypeError: wrong argument type Fixnum (expected Symbol)
puts(**{c: 4}, **{'b' => 1})           # TypeError: wrong argument type Fixnum (expected Symbol)
puts(**{c: 4}, a: 3, **{'b' => 1})     # TypeError: wrong argument type Fixnum (expected Symbol)
```

What's basically going on is this: you can double splat hashes with no symbol keys all you want, only if the first value of the hash is a regular key (symbol or not) and not a splatted hash, or also a double splatted empty hash.


It feels strange that building the same hash in different orders yields so different behaviors. 
Anyhow, I personally feel it should be a bug if you cannot splat a hash with no symbol keys into another one, whichever are the remaining values of the hash.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:73958] [Ruby trunk Bug#12106] Behavior of double splatting of hashes with non symbol key is different according to splatted hash position
       [not found] <redmine.issue-12106.20160224042950@ruby-lang.org>
  2016-02-24  4:29 ` [ruby-core:73957] [Ruby trunk Bug#12106] Behavior of double splatting of hashes with non symbol key is different according to splatted hash position pablodherrero
@ 2016-02-24  4:33 ` pablodherrero
  2016-03-16  9:41 ` [ruby-core:74375] [Ruby trunk Bug#12106][Assigned] " shyouhei
  2019-10-21 16:56 ` [ruby-core:95459] [Ruby master Bug#12106] " merch-redmine
  3 siblings, 0 replies; 4+ messages in thread
From: pablodherrero @ 2016-02-24  4:33 UTC (permalink / raw)
  To: ruby-core

Issue #12106 has been updated by Pablo Herrero.


Small correction: for the 2nd, 3rd and 4th examples the error actually is "# TypeError: wrong argument type String (expected Symbol)"

----------------------------------------
Bug #12106: Behavior of double splatting of hashes with non symbol key is different according to splatted hash position
https://bugs.ruby-lang.org/issues/12106#change-57107

* Author: Pablo Herrero
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
When doing double splatting with hash with non symbols keys you get different behaviors according to the position of the hash been splatted:

```ruby
{a: 3, **{b: 1}, **{'b' => 1}}     # Works fine
{a: 3, **{1 => 1}, **{b: 1}}       # Works fine
{3 => 3, **{b: 1}, **{'b' => 1}}   # Works fine
{**{}, a: 3, **{b: 1}, **{1 => 1}} # Works fine

{**{b: 1}, a: 3, **{1 => 1}}       # TypeError: wrong argument type Fixnum (expected Symbol)
{**{'b' => 1}, **{c: 4}}           # TypeError: wrong argument type Fixnum (expected Symbol)
{**{c: 4}, **{'b' => 1}}           # TypeError: wrong argument type Fixnum (expected Symbol)
{**{c: 4}, a: 3, **{'b' => 1}}     # TypeError: wrong argument type Fixnum (expected Symbol)
```

Same thing happens when you double splat inside a message send:


```ruby
puts(a: 3, **{b: 1}, **{'b' => 1})     # Works fine
puts(a: 3, **{1 => 1}, **{b: 1})       # Works fine
puts(3 => 3, **{b: 1}, **{'b' => 1})   # Works fine
puts(**{}, a: 3, **{b: 1}, **{1 => 1}) # Works fine

puts(**{b: 1}, a: 3, **{1 => 1})       # TypeError: wrong argument type Fixnum (expected Symbol)
puts(**{'b' => 1}, **{c: 4})           # TypeError: wrong argument type Fixnum (expected Symbol)
puts(**{c: 4}, **{'b' => 1})           # TypeError: wrong argument type Fixnum (expected Symbol)
puts(**{c: 4}, a: 3, **{'b' => 1})     # TypeError: wrong argument type Fixnum (expected Symbol)
```

What's basically going on is this: you can double splat hashes with no symbol keys all you want, only if the first value of the hash is a regular key (symbol or not) and not a splatted hash, or also a double splatted empty hash.


It feels strange that building the same hash in different orders yields so different behaviors. 
Anyhow, I personally feel it should be a bug if you cannot splat a hash with no symbol keys into another one, whichever are the remaining values of the hash.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:74375] [Ruby trunk Bug#12106][Assigned] Behavior of double splatting of hashes with non symbol key is different according to splatted hash position
       [not found] <redmine.issue-12106.20160224042950@ruby-lang.org>
  2016-02-24  4:29 ` [ruby-core:73957] [Ruby trunk Bug#12106] Behavior of double splatting of hashes with non symbol key is different according to splatted hash position pablodherrero
  2016-02-24  4:33 ` [ruby-core:73958] " pablodherrero
@ 2016-03-16  9:41 ` shyouhei
  2019-10-21 16:56 ` [ruby-core:95459] [Ruby master Bug#12106] " merch-redmine
  3 siblings, 0 replies; 4+ messages in thread
From: shyouhei @ 2016-03-16  9:41 UTC (permalink / raw)
  To: ruby-core

Issue #12106 has been updated by Shyouhei Urabe.

Status changed from Open to Assigned
Assignee set to Nobuyoshi Nakada

----------------------------------------
Bug #12106: Behavior of double splatting of hashes with non symbol key is different according to splatted hash position
https://bugs.ruby-lang.org/issues/12106#change-57495

* Author: Pablo Herrero
* Status: Assigned
* Priority: Normal
* Assignee: Nobuyoshi Nakada
* ruby -v: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
When doing double splatting with hash with non symbols keys you get different behaviors according to the position of the hash been splatted:

```ruby
{a: 3, **{b: 1}, **{'b' => 1}}     # Works fine
{a: 3, **{1 => 1}, **{b: 1}}       # Works fine
{3 => 3, **{b: 1}, **{'b' => 1}}   # Works fine
{**{}, a: 3, **{b: 1}, **{1 => 1}} # Works fine

{**{b: 1}, a: 3, **{1 => 1}}       # TypeError: wrong argument type Fixnum (expected Symbol)
{**{'b' => 1}, **{c: 4}}           # TypeError: wrong argument type Fixnum (expected Symbol)
{**{c: 4}, **{'b' => 1}}           # TypeError: wrong argument type Fixnum (expected Symbol)
{**{c: 4}, a: 3, **{'b' => 1}}     # TypeError: wrong argument type Fixnum (expected Symbol)
```

Same thing happens when you double splat inside a message send:


```ruby
puts(a: 3, **{b: 1}, **{'b' => 1})     # Works fine
puts(a: 3, **{1 => 1}, **{b: 1})       # Works fine
puts(3 => 3, **{b: 1}, **{'b' => 1})   # Works fine
puts(**{}, a: 3, **{b: 1}, **{1 => 1}) # Works fine

puts(**{b: 1}, a: 3, **{1 => 1})       # TypeError: wrong argument type Fixnum (expected Symbol)
puts(**{'b' => 1}, **{c: 4})           # TypeError: wrong argument type Fixnum (expected Symbol)
puts(**{c: 4}, **{'b' => 1})           # TypeError: wrong argument type Fixnum (expected Symbol)
puts(**{c: 4}, a: 3, **{'b' => 1})     # TypeError: wrong argument type Fixnum (expected Symbol)
```

What's basically going on is this: you can double splat hashes with no symbol keys all you want, only if the first value of the hash is a regular key (symbol or not) and not a splatted hash, or also a double splatted empty hash.


It feels strange that building the same hash in different orders yields so different behaviors. 
Anyhow, I personally feel it should be a bug if you cannot splat a hash with no symbol keys into another one, whichever are the remaining values of the hash.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:95459] [Ruby master Bug#12106] Behavior of double splatting of hashes with non symbol key is different according to splatted hash position
       [not found] <redmine.issue-12106.20160224042950@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2016-03-16  9:41 ` [ruby-core:74375] [Ruby trunk Bug#12106][Assigned] " shyouhei
@ 2019-10-21 16:56 ` merch-redmine
  3 siblings, 0 replies; 4+ messages in thread
From: merch-redmine @ 2019-10-21 16:56 UTC (permalink / raw)
  To: ruby-core

Issue #12106 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Assigned to Closed

With the changes in #14183, TypeError is no longer raised in any of the examples, as non-Symbol keys can be used inside a hash that is double splatted.

----------------------------------------
Bug #12106: Behavior of double splatting of hashes with non symbol key is different according to splatted hash position
https://bugs.ruby-lang.org/issues/12106#change-82211

* Author: pabloh (Pablo Herrero)
* Status: Closed
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version: 
* ruby -v: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
When doing double splatting with hash with non symbols keys you get different behaviors according to the position of the hash been splatted:

```ruby
{a: 3, **{b: 1}, **{'b' => 1}}     # Works fine
{a: 3, **{1 => 1}, **{b: 1}}       # Works fine
{3 => 3, **{b: 1}, **{'b' => 1}}   # Works fine
{**{}, a: 3, **{b: 1}, **{1 => 1}} # Works fine

{**{b: 1}, a: 3, **{1 => 1}}       # TypeError: wrong argument type Fixnum (expected Symbol)
{**{'b' => 1}, **{c: 4}}           # TypeError: wrong argument type Fixnum (expected Symbol)
{**{c: 4}, **{'b' => 1}}           # TypeError: wrong argument type Fixnum (expected Symbol)
{**{c: 4}, a: 3, **{'b' => 1}}     # TypeError: wrong argument type Fixnum (expected Symbol)
```

Same thing happens when you double splat inside a message send:


```ruby
puts(a: 3, **{b: 1}, **{'b' => 1})     # Works fine
puts(a: 3, **{1 => 1}, **{b: 1})       # Works fine
puts(3 => 3, **{b: 1}, **{'b' => 1})   # Works fine
puts(**{}, a: 3, **{b: 1}, **{1 => 1}) # Works fine

puts(**{b: 1}, a: 3, **{1 => 1})       # TypeError: wrong argument type Fixnum (expected Symbol)
puts(**{'b' => 1}, **{c: 4})           # TypeError: wrong argument type Fixnum (expected Symbol)
puts(**{c: 4}, **{'b' => 1})           # TypeError: wrong argument type Fixnum (expected Symbol)
puts(**{c: 4}, a: 3, **{'b' => 1})     # TypeError: wrong argument type Fixnum (expected Symbol)
```

What's basically going on is this: you can double splat hashes with no symbol keys all you want, only if the first value of the hash is a regular key (symbol or not) and not a splatted hash, or also a double splatted empty hash.


It feels strange that building the same hash in different orders yields so different behaviors. 
Anyhow, I personally feel it should be a bug if you cannot splat a hash with no symbol keys into another one, whichever are the remaining values of the hash.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-10-21 16:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-12106.20160224042950@ruby-lang.org>
2016-02-24  4:29 ` [ruby-core:73957] [Ruby trunk Bug#12106] Behavior of double splatting of hashes with non symbol key is different according to splatted hash position pablodherrero
2016-02-24  4:33 ` [ruby-core:73958] " pablodherrero
2016-03-16  9:41 ` [ruby-core:74375] [Ruby trunk Bug#12106][Assigned] " shyouhei
2019-10-21 16:56 ` [ruby-core:95459] [Ruby master Bug#12106] " merch-redmine

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).