Bug #1979: parser confused by local variable assignment
http://redmine.ruby-lang.org/issues/show/1979

Author: caleb clausen
Status: Open, Priority: Normal
ruby -v: 1.8 and up

I posted this before as a followup to bug #1801. Since there was no response and it seems to have been fixed independently of #1801 in the distant past, I'm filing it as a separate bug.

I can't decide if this is a different manifestation of bug #1801 or just a highly similar bug, maybe someone can enlighten me:

  p = p m %(2)

I think the %(2) should be treated as a string, since it is in all other cases I know of (unless m is an lvar, which obviously it isn't here). However, it gets parsed as an operator and a parenthesized numeric literal.

In this variation of the expression, %(2) is a string, as I would expect:

  p m %(2)

Is this the same as #1801?

This expression works as I expected for versions 1.4.0 thru 1.7.1. All versions after 1.7.1 don't work the way I expect. In versions before 1.4.0 it causes a syntax error. Jruby has identical behavior as recent mri rubies. In rubinius, it causes a stack dump.

Something interesting happened around about 1.7.1.


----------------------------------------
http://redmine.ruby-lang.org