ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:95951] [Ruby master Bug#16371] Inconsistent usage of Double splat operator
       [not found] <redmine.issue-16371.20191126065007@ruby-lang.org>
@ 2019-11-26  6:50 ` dmytro.vasin
  2019-11-26  7:32 ` [ruby-core:95952] " mame
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: dmytro.vasin @ 2019-11-26  6:50 UTC (permalink / raw
  To: ruby-core

Issue #16371 has been reported by dmytro.vasin (Dmytro Vasin).

----------------------------------------
Bug #16371: Inconsistent usage of Double splat operator
https://bugs.ruby-lang.org/issues/16371

* Author: dmytro.vasin (Dmytro Vasin)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.6.0
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Here is an issue with wierd behavior of a ruby double splat operator: 

```
a = {a: 'a'}
b = {'b' => 'b'}

{x: 'x', **a}
#=> {:x=>"x", :a=>"a"}

{x: 'x', **b}
#=> TypeError (hash key "b" is not a Symbol)
```

But when I do that implicitly it works:
```
{x: 'x', **{'b' => 'b'}} 
#=> {:x=>"x", "b"=>"b"}
```

In the same time: 
```
{**{'b' => 'b'}}
# TypeError (hash key "b" is not a Symbol)
```

From my point of view, it definitely works inconsistently

Could you help with that example or give advice? ( maybe I incorrectly use it? ) 



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

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

* [ruby-core:95952] [Ruby master Bug#16371] Inconsistent usage of Double splat operator
       [not found] <redmine.issue-16371.20191126065007@ruby-lang.org>
  2019-11-26  6:50 ` [ruby-core:95951] [Ruby master Bug#16371] Inconsistent usage of Double splat operator dmytro.vasin
@ 2019-11-26  7:32 ` mame
  2019-11-27  1:35 ` [ruby-core:95970] " matz
  2019-11-27  3:06 ` [ruby-core:95972] " mame
  3 siblings, 0 replies; 4+ messages in thread
From: mame @ 2019-11-26  7:32 UTC (permalink / raw
  To: ruby-core

Issue #16371 has been updated by mame (Yusuke Endoh).


`**` operator is for keyword arguments, and in Ruby 2.6, non-symbol key is not allowed in keyword arguments.  So in principle, `{x: 'x', **{'b' => 'b'}}` should raise an exception.

Because of the spec change of keyword arguments (#14183), non-symbol key is allowed in Ruby 2.7, and all shown cases work without exception.

Do you want the case to raise an exception in Ruby 2.6?

----------------------------------------
Bug #16371: Inconsistent usage of Double splat operator
https://bugs.ruby-lang.org/issues/16371#change-82787

* Author: dmytro.vasin (Dmytro Vasin)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.6.0
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Here is an issue with wierd behavior of a ruby double splat operator: 

```
a = {a: 'a'}
b = {'b' => 'b'}

{x: 'x', **a}
#=> {:x=>"x", :a=>"a"}

{x: 'x', **b}
#=> TypeError (hash key "b" is not a Symbol)
```

But when I do that implicitly it works:
```
{x: 'x', **{'b' => 'b'}} 
#=> {:x=>"x", "b"=>"b"}
```

In the same time: 
```
{**{'b' => 'b'}}
# TypeError (hash key "b" is not a Symbol)
```

From my point of view, it definitely works inconsistently

Could you help with that example or give advice? ( maybe I incorrectly use it? ) 



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

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

* [ruby-core:95970] [Ruby master Bug#16371] Inconsistent usage of Double splat operator
       [not found] <redmine.issue-16371.20191126065007@ruby-lang.org>
  2019-11-26  6:50 ` [ruby-core:95951] [Ruby master Bug#16371] Inconsistent usage of Double splat operator dmytro.vasin
  2019-11-26  7:32 ` [ruby-core:95952] " mame
@ 2019-11-27  1:35 ` matz
  2019-11-27  3:06 ` [ruby-core:95972] " mame
  3 siblings, 0 replies; 4+ messages in thread
From: matz @ 2019-11-27  1:35 UTC (permalink / raw
  To: ruby-core

Issue #16371 has been updated by matz (Yukihiro Matsumoto).


I think this inconsistency is a bug. Double splat in hash expressions needs to work as interpolation.

Matz.


----------------------------------------
Bug #16371: Inconsistent usage of Double splat operator
https://bugs.ruby-lang.org/issues/16371#change-82805

* Author: dmytro.vasin (Dmytro Vasin)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.6.0
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Here is an issue with a weird behavior of ruby double splat operator: 

```
a = {a: 'a'}
b = {'b' => 'b'}

{x: 'x', **a}
#=> {:x=>"x", :a=>"a"}

{x: 'x', **b}
#=> TypeError (hash key "b" is not a Symbol)
```

When I do that implicitly, it works:

```
{x: 'x', **{'b' => 'b'}} 
#=> {:x=>"x", "b"=>"b"}
```

At the same time:

```
{**{'b' => 'b'}}
# TypeError (hash key "b" is not a Symbol)
```

From my point of view, it definitely works inconsistently.

Could you help with this example or give an advice? (maybe I used it incorrectly?)



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

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

* [ruby-core:95972] [Ruby master Bug#16371] Inconsistent usage of Double splat operator
       [not found] <redmine.issue-16371.20191126065007@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2019-11-27  1:35 ` [ruby-core:95970] " matz
@ 2019-11-27  3:06 ` mame
  3 siblings, 0 replies; 4+ messages in thread
From: mame @ 2019-11-27  3:06 UTC (permalink / raw
  To: ruby-core

Issue #16371 has been updated by mame (Yusuke Endoh).


matz, the following is the current behaviors.  Do you mean which should be fixed?

(1) 2.7, via variable

```
b = {"b" => "b"}; p({x: "x", **b}) #=> current behavior: {:x=>"x", "b"=>"b"}
```

(2) 2.6, via variable

```
b = {"b" => "b"}; p({x: "x", **b}) #=> current behavior: hash key "b" is not a Symbol (TypeError)
```

(3) 2.7, with literal

```
p({x: "x", **{"b" => "b"}}) #=> current behavior: {:x=>"x", "b"=>"b"}
```

(4) 2.6, with literal

```
p({x: "x", **{"b" => "b"}}) #=> current behavior: {:x=>"x", "b"=>"b"}
```

----------------------------------------
Bug #16371: Inconsistent usage of Double splat operator
https://bugs.ruby-lang.org/issues/16371#change-82807

* Author: dmytro.vasin (Dmytro Vasin)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.6.0
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Here is an issue with a weird behavior of ruby double splat operator: 

```
a = {a: 'a'}
b = {'b' => 'b'}

{x: 'x', **a}
#=> {:x=>"x", :a=>"a"}

{x: 'x', **b}
#=> TypeError (hash key "b" is not a Symbol)
```

When I do that implicitly, it works:

```
{x: 'x', **{'b' => 'b'}} 
#=> {:x=>"x", "b"=>"b"}
```

At the same time:

```
{**{'b' => 'b'}}
# TypeError (hash key "b" is not a Symbol)
```

From my point of view, it definitely works inconsistently.

Could you help with this example or give an advice? (maybe I used it incorrectly?)



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

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

end of thread, other threads:[~2019-11-27  3:06 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-16371.20191126065007@ruby-lang.org>
2019-11-26  6:50 ` [ruby-core:95951] [Ruby master Bug#16371] Inconsistent usage of Double splat operator dmytro.vasin
2019-11-26  7:32 ` [ruby-core:95952] " mame
2019-11-27  1:35 ` [ruby-core:95970] " matz
2019-11-27  3:06 ` [ruby-core:95972] " mame

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).