jruby/jruby — pull request #1054 by 97jaz (2013-09-30 20:08:39+00:00)
Title: Fixes for keyword argument handling

[This supersedes my previous PR: 1047-kwargs.]

* If you pass an explicit nil as the value of a keyword argument, we need to use that nil rather than the default value. Example:

```ruby
def test(foo: 10)
foo
end

test(foo: nil)
```
... should produce nil.

* The kw assignment code in ArgsNode.java was consider a hash as the last argument to a method expecting kw arguments to be necessarily a hash of kw values. However, this isn't always true. E.g.:

```ruby
def test(foo, bar: 10)
[foo, bar]
end

test(no: "way")
```
...should produce [{:no=>"way"}, 10]

* The arity checks occurring at lines 285 and 303 in Arity.java defer a check to kw assignment time, because not enough information is provided to the checking method to determine if there is an error. (Maybe this should be changed, but that's a much larger change than what I'm proposing.) However, that deferred check was not actually being performed. Example:

```ruby
def test(foo: 10)
foo
end

test(3)
```
... should raise an ArgumentError.

* Keyword values passed to a method could be treated both as keyword arguments and as optional or rest arguments, because the code responsible for binding optional and rest arguments were not aware of keyword arguments. Example:

```ruby
def test(a = true, foo: 10)
[a, foo]
end

test(foo: 78)
```
... should produce [true, 78]

and
```ruby

def test(*opts, foo: 10)
[opts, foo]
end

test(foo: 3)
```
... should produce [[], 3]

***

I would be more than happy to add these examples as tests, but I can't tell how I would add 2.0-specific tests. If someone could point me in the right direction, I'll add tests to this PR.