Ruby 1.9, keyword arguments, WTF

Amongst the many entries Ruby has in the "you have got to be kidding me" stakes, this is a doozy.

Due to Ruby's lack of explicit support for keyword arguments, it's traditional to use a quirk of its argument parsing that pushes named arguments into a hash:

def foo (a, kwargs={})
        print a
        print kwargs

foo(1) # prints "1" and "{}"
foo(1, :a=>2) # prints "1" and "{:a=>2}"

However, should you be so unwise as to insert a space between the function name and arguments:

foo (1, :a=>2)

you'll get an extremely unhelpful error message:

SyntaxError: (irb):5: syntax error, unexpected ',', expecting ')'

The error is being pinpointed in the argument list although it is actually being caused by the space between the function name and parens. It appears that this problem was introduced in 1.9 (see comments on this article).