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

parser bug #1887

Closed
godfat opened this issue Aug 4, 2014 · 7 comments
Closed

parser bug #1887

godfat opened this issue Aug 4, 2014 · 7 comments

Comments

@godfat
Copy link
Contributor

godfat commented Aug 4, 2014

Below don't compile on JRuby:

$ jruby --2.0 -vc parser-bug.rb
jruby 1.7.13 (2.0.0p195) 2014-06-24 43f133c on OpenJDK 64-Bit Server VM 1.7.0_65-b32 [linux-amd64]
SyntaxError in parser-bug.rb:8: syntax error, unexpected kDO_BLOCK
    d.e do
^

While:

$ ruby -vc parser-bug.rb
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
Syntax OK
$ rbx -vc parser-bug.rb
rubinius 2.2.10 (2.1.0 bf61ae2e 2014-06-27 JI) [x86_64-linux-gnu]
Syntax OK

Here's parser-bug.rb:

include Module.new{
  def a
    "#{b}"
  end

  def c
    d.e do
    end
  end
}
@headius
Copy link
Member

headius commented Aug 5, 2014

2.0 mode in JRuby 1.7 has always been experimental, so without community help we probably won't be fixing 2.0 issues. Try out master...it is not optimized yet but should support full 2.1 syntax.

@godfat
Copy link
Contributor Author

godfat commented Aug 5, 2014

I don't have other 1.9 rubies on hands at the moment, but I believe this should be a valid syntax on 1.9, too, and JRuby 1.9 mode also has this issue.

I would try master, but it failed to build a few hours I tried. I would try again.

@godfat
Copy link
Contributor Author

godfat commented Aug 5, 2014

Confirmed.

$ ./bin/jruby -vc parser-bug.rb
jruby 9000.dev-SNAPSHOT (2.1.2) 2014-08-05 28b48f5 OpenJDK 64-Bit Server VM 24.65-b04 on 1.7.0_65-b32 [linux-amd64]
/home/godfat/jruby/lib/ruby/shared/jar_installer.rb:10 warning: Ambiguous first argument; make sure.
/home/godfat/jruby/lib/ruby/shared/jar_installer.rb:16 warning: Ambiguous first argument; make sure.
/home/godfat/jruby/lib/ruby/shared/jar_installer.rb:18 warning: Ambiguous first argument; make sure.
/home/godfat/jruby/lib/ruby/shared/jar_installer.rb:47 warning: Ambiguous first argument; make sure.
SyntaxError in parser-bug.rb:7: syntax error, unexpected kDO_BLOCK
    d.e do
^

@headius
Copy link
Member

headius commented Aug 5, 2014

OK sure! Now that's something we can look into :-)

@godfat
Copy link
Contributor Author

godfat commented Aug 5, 2014

Great. Sorry for not reporting this against master first.

@enebo
Copy link
Member

enebo commented Aug 6, 2014

Reduced this a tiny bit more:

include Module.new {
  "#{b}"

  d.e do
  end
}

This is another variant of an older bug involving the {} of Module going down a different part of the parser than MRI (I never figured out why so I hacked around it and this is exposing that the hack was not 100% soln). I think the issue is that in this other branch it is unable to handle these other constructs. It is weird that the string interpolation is needed for 'd.e do' to fail. As a workaround I believe changing {} to do or using parens around include will for until this is resolved.

@godfat
Copy link
Contributor Author

godfat commented Aug 6, 2014

I guess the parser might enter a weird state whenever it saw a string interpolation in this case. I would try and see if I could find anything in the parser code if I have time.

Using parens for calling include did work, but using do end won't because then do end would be associated to include rather than Module.new. For now I assign the new module to a local variable and include that variable instead.

@enebo enebo added the parser label Jun 12, 2015
@enebo enebo added this to the JRuby 9.0.0.0.rc2 milestone Jun 12, 2015
@enebo enebo closed this as completed in a57eba4 Jun 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants