MRI 1.9 & JRuby 1.7 Parsing Inconsistency #503

Closed
yfeldblum opened this Issue Jan 20, 2013 · 2 comments

Projects

None yet

3 participants

@yfeldblum

The following snippet parses in ruby-1.9.2-p320 and ruby-1.9.3-p327.

def a(arg)
  puts arg + yield
end

def b
  return a "xyz" do
    "xyz"
  end
end

b

Running this snippet in either of the above implementations prints xyzxyz to stdout.

However, the snippet fails to parse in jruby 1.7.2 (1.9.3p327):

Ruby19Parser.java:3393:in `execute': java.lang.ClassCastException:
  org.jruby.ast.ReturnNode cannot be cast to org.jruby.ast.BlockAcceptingNode
    from Ruby19Parser.java:1502:in `yyparse'
    from Ruby19Parser.java:1393:in `yyparse'
    from Ruby19Parser.java:4300:in `parse'
    from Parser.java:114:in `parse'
    from Parser.java:95:in `parse'
    from Ruby.java:2464:in `parseFileFromMain'
    from Ruby.java:545:in `parseFromMain'
    from Ruby.java:507:in `runFromMain'
    from Main.java:390:in `doRunFromMain'
    from Main.java:279:in `internalRun'
    from Main.java:221:in `run'
    from Main.java:201:in `main'
@shepmaster

A workaround is to use return a("xyz") do. Perhaps the parsing precedence is backwards in this case.

@enebo
Member
enebo commented Jan 21, 2013

This is a duplicate of #305 so I will close this one. Please follow that one. This parser bug has been known for a long time but the solution has been elusive thus far.

@enebo enebo closed this Jan 21, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment