jruby / jruby-parser

JRuby's parser customized for IDE usage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Some variants of the || operator are parsed like calls

chrisseaton opened this issue · comments

It looks like some variants of the || operator come out as if they are calls, when they should only ever be special 'or' nodes.

For example this:

foo[bar] ||= baz

Parses as this:

(RootNode,
    (NewlineNode,
        (OpElementAsgnNode,
            (VCallNode:foo),
            (ArrayNode, (VCallNode:bar)),
        (VCallNode:baz))))

With the operator name of OpElementAsgnNode being "||". That makes it look like a call, when it's something else entirely. Unless you look specifically for "||", you're going to assume that this is a call and not realise until the "||" method isn't found later.

I'd suggest that we have a special version of OpElementAsgnNode for And and Or, something like OpElementAsgnOrNode, like we do with OpAsgnOrNode.

I agree with this issue for ||, and &&. I believe all others are actually calls not a builtin operator. If there are more then I think we should add those as well. Interestingly enough OpAsgnNode does have special nodes for these. It is just not done for OpElement versions?

Two new classes OpElementAsgnOrNode and OpElementAsgnAndNode. These extend OpElementAsgnNode and the same visitor visits all three. instanceof/kind_of? can both be used to discriminate in the visitor. I could add more visitor nodes but let's see how this works first.