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

Passing nil as the value of a keyword argument causes JRuby to act as if there were no such keyword argument #1047

Closed
97jaz opened this Issue Sep 30, 2013 · 2 comments

Comments

Projects
None yet
2 participants
@97jaz
Copy link
Contributor

97jaz commented Sep 30, 2013

The following simple program demonstrates the problem:

def test(foo: 10)
  foo
end

test(foo: nil)

MRI:

2.0.0p247 :006 > test(foo: nil)
 => nil

JRuby:

jruby-1.7.4 :005 >   test(foo: nil)
ArgumentError: unknown keyword: foo
    from (irb):5:in `evaluate'
    from org/jruby/RubyKernel.java:1093:in `eval'
    from org/jruby/RubyKernel.java:1489:in `loop'
    from org/jruby/RubyKernel.java:1254:in `catch'
    from org/jruby/RubyKernel.java:1254:in `catch'
    from /Users/jaz/.rvm/rubies/jruby-1.7.4/bin/irb:13:in `(root)'
@97jaz

This comment has been minimized.

Copy link
Contributor Author

97jaz commented Sep 30, 2013

The cause appears to be the conditional at: https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/ast/ArgsNode.java#L488

This code needs to distinguish between the absence of a keyword value and an explicitly provided nil. I should be able to provide a patch, I think.

@headius

This comment has been minimized.

Copy link
Member

headius commented Oct 1, 2013

Fixed by #1054.

@headius headius closed this Oct 1, 2013

headius added a commit that referenced this issue Oct 1, 2013

Fixes JRuby #1047 - incorrect test for whether a kw arg was provided.
Formerly, the code attempted to extract the argument value from the
hash of provided values and test it against nil. This fails in the
case of an explicitly passed nil. The new version instead tests
whether the hash contains the desired key.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.