seattlerb/ruby_parser — Issue #29: Ruby 1.9 hash syntax cause problems when used as method arguments
Author: k33l0r
Created: 2011-11-29 12:23:21+00:00
State: open

If you use the new hash syntax causes an explosion:

```ruby
# hash19.rb
foo(hash: :bar)
```

Results in this:

```
$ ruby_parse hash19.rb
# file = hash_test.rb loc = 0
/Users/matt/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/racc/parser.rb:351:in `on_error' # for hash_test.rb
/Users/matt/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/racc/parser.rb:351:in `on_error'
(eval):3:in `_racc_do_parse_c'
(eval):3:in `do_parse'
/Users/matt/.rvm/gems/ruby-1.9.3-p0/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:750:in `process'
/Users/matt/.rvm/gems/ruby-1.9.3-p0/gems/ruby_parser-2.3.1/bin/ruby_parse:40:in `block in '
/Users/matt/.rvm/gems/ruby-1.9.3-p0/gems/ruby_parser-2.3.1/bin/ruby_parse:21:in `each'
/Users/matt/.rvm/gems/ruby-1.9.3-p0/gems/ruby_parser-2.3.1/bin/ruby_parse:21:in `'
/Users/matt/.rvm/gems/ruby-1.9.3-p0/bin/ruby_parse:19:in `load'
/Users/matt/.rvm/gems/ruby-1.9.3-p0/bin/ruby_parse:19:in `

'
done
```

If you use the "old" syntax everything works fine:

```ruby
# hash18.rb
foo(:hash => :bar)
```

```
$ ruby_parse hash18.rb
# file = hash_test.rb loc = 0
s(:call, nil, :foo, s(:arglist, s(:hash, s(:lit, :hash), s(:lit, :bar))))
done
```

It also works fine if you have curly braces around the hash:

```ruby
# hash19_curly.rb
foo({hash: :bar})
```

```
$ ruby_parse hash_test.rb
# file = hash_test.rb loc = 0
nil
done
```