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

Another unexpected kDO_BLOCK error in parser #1629

jlukas opened this issue Apr 14, 2014 · 4 comments

Another unexpected kDO_BLOCK error in parser #1629

jlukas opened this issue Apr 14, 2014 · 4 comments


Copy link

@jlukas jlukas commented Apr 14, 2014

JRuby throws a syntax error where Ruby 1.9 does not:

% rvm 1.9 do irb
1.9.3-p545 :001 >   some_method key: (proc do
1.9.3-p545 :002 >           {
1.9.3-p545 :003 >               key: "#{var}#{var}",
1.9.3-p545 :004 >               other_key: proc do
1.9.3-p545 :005 >                 end
1.9.3-p545 :006?>           }
1.9.3-p545 :007?>       end)
NoMethodError: undefined method `some_method' for main:Object
    from (irb):7
    from /Users/jlukas/.rvm/rubies/ruby-1.9.3-p545/bin/irb:12:in `<main>'
1.9.3-p545 :008 > exit
% rvm jruby do irb
jruby-1.7.11 :001 >   some_method key: (proc do
jruby-1.7.11 :002 >           {
jruby-1.7.11 :003 >               key: "#{var}#{var}",
jruby-1.7.11 :004 >               other_key: proc do
jruby-1.7.11 :005 >                 end
jruby-1.7.11 :006?>           }
jruby-1.7.11 :007?>       end)
SyntaxError: (irb):4: syntax error, unexpected kDO_BLOCK
      other_key: proc do
    from org/jruby/ `eval'
    from org/jruby/ `loop'
    from org/jruby/ `catch'
    from org/jruby/ `catch'
    from /Users/jlukas/.rvm/rubies/jruby-1.7.11/bin/irb:13:in `(root)'
jruby-1.7.11 :008 > 
Copy link

@olleolleolle olleolleolle commented Apr 29, 2014

Hello @jlukas. Cool find, and potentially quite relevant to DSL authors.

I propose you rename this issue to something more descriptive such as "JRuby can raise a SyntaxError where MRI1.9 raises a NoMethodError".

@enebo enebo changed the title Syntax Error Another unexpected kDO_BLOCK error in parser Apr 29, 2014
Copy link

@headius headius commented Nov 12, 2014

Still a problem in JRuby 9k-pre1.

Copy link

@jeremybmerrill jeremybmerrill commented Apr 7, 2015

I'm not sure if this is the same issue, but I think it may be -- involving parentheses around a multiline do...end block. This is valid syntax in MRE 2.2.1, but I get a syntax error in JRuby 1.7.19

$ cat minimal_kdoblock.rb 
puts ( do |i|
  7 + i
$ rbenv local 2.2.1
$ ruby minimal_kdoblock.rb 
[7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
$ rbenv local jruby-1.7.19 
$ ruby minimal_kdoblock.rb 
SyntaxError: minimal_kdoblock.rb:2: syntax error, unexpected kDO_BLOCK
puts ( do |i|

If it's different, let me know and I'd be happy to open a different issue. If there's anything useful I can do to help, please let me know. Thanks for your help and with JRuby generally, it's an amazing help in a bunch of my projects!

@enebo enebo removed the ruby 1.9 label Jun 5, 2015
Copy link

@enebo enebo commented Jun 5, 2015

I just realized this only works 2.0+ as valid syntax. Fix coming momentarily for 9k.

@enebo enebo added this to the JRuby milestone Jun 5, 2015
@enebo enebo closed this in 8f4ec6b Jun 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants