jruby / jruby-parser

JRuby's parser customized for IDE usage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why does the 1.8 parser pass a different name for unary operators than 1.9?

chrisseaton opened this issue · comments

Compare line 821 of Ruby19Parser.y of 797 of Ruby18Parser.y. The 1.9 parser sets the correct name of the method, which is -@, whereas 1.8 doesn't set the name, so I think it takes the name from the token, "-".

This means that when I get an AST using the 1.9 parser, the methods which are actually -@ are reported as -, and there's no way to tell that they were ever unary (maybe guessing based on node locations or something).

Is this right? I don't think there's anything that changed between 1.8 and 1.9 that means that you'd want to treat unary methods differently?

This was a backport from JRuby proper to JRuby-Parser and there are some semantic changes between 1.8 and 1.9 between a few special operators like '!'. In this case I think this was just how 1.9 changed the code (in MRI) and I agree we do want to know that it is a '-@'. If you are game to make a PR I think you could unify both sites you specified to use the 1.9 getOperatorCallNode(Token, Node).

I also wonder about whether how 1.9 stores this as '-@' as the operator name will play out in the rewriter. getName() probably returns this which would cause -1 to rewrite back as -@1. This is a different issue though and one which will probably be one of many changes once rewriting is scrutinized more.