Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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 · 2 comments

2 participants

97jaz Charles Oliver Nutter
97jaz

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

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.

97jaz 97jaz referenced this issue from a commit in 97jaz/jruby
97jaz 97jaz 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.
21248c4
Charles Oliver Nutter
Owner

Fixed by #1054.

Charles Oliver Nutter headius closed this
Charles Oliver Nutter headius referenced this issue from a commit
97jaz 97jaz 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.
8d74e67
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.