Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double-splat should not work with non-symbol keys #4055

Closed
ivoanjo opened this issue Aug 9, 2016 · 1 comment
Closed

Double-splat should not work with non-symbol keys #4055

ivoanjo opened this issue Aug 9, 2016 · 1 comment

Comments

@ivoanjo
Copy link
Contributor

ivoanjo commented Aug 9, 2016

So for curiosity I ran a codebase which has been using JRuby from day one through MRI and some of the specs started failing. Looking at it, it seems JRuby is much more permissive than MRI with the double-splat, which in this case led my team to write code that is accepted by JRuby (and passes the specs) but is wrong as seen by MRI.

Environment

Running jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f OpenJDK 64-Bit Server VM 25.91-b14 on 1.8.0_91-8u91-b14-3ubuntu1~15.10.1-b14 [linux-x86_64] on Ubuntu 15.10.

Expected Behavior

Example code:

foo = {1 => 'hello', 'world' => 'foo', Object.new => 'bar'}

baz = {**foo}

puts baz

Output in MRI 2.3.1:

example.rb:3:in `<main>': wrong argument type Fixnum (expected Symbol) (TypeError)

Actual Behavior

Output in JRuby:

{1=>"hello", "world"=>"foo", #<Object:0x3b0143d3>=>"bar"}

(E.g. JRuby is happy to allow double-splatting of non-symbol keys).

@enebo enebo added this to the JRuby 9.1.3.0 milestone Aug 9, 2016
@enebo
Copy link
Member

enebo commented Aug 9, 2016

This is a variant of another problem we knew we had. The other issue (don't see it offhand in our tracker) we need to split incoming symbol from non-symbol keys on the receiving side. Your bug is on the other end that kwarg-splatting does not allow that mixture at all.

@enebo enebo closed this as completed in 1ec8b39 Aug 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants