Did you check existing issues?
Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)
No response
Describe the bug
I'm working on an ast-grep version of the Rubocop ambiguous operator lint. One of the cases it needs to alert on is something +x and something -y.
When I do something -y I get an AST like this:
But when I do something +x I get a binary in the AST instead of a unary as expected:
Ruby alerts on both of these, showing that it parses both of these as a unary:
def do_something(x); end
do_something +42
do_something -42
# Running that gives us this:
/Users/samwightt/Code/ruby/ast-grep-rubocop/demo_ambiguous_operators.rb:3: warning: ambiguous first argument; put parentheses or a space even after `+` operator
/Users/samwightt/Code/ruby/ast-grep-rubocop/demo_ambiguous_operators.rb:4: warning: ambiguous first argument; put parentheses or a space even after `-` operator
Steps To Reproduce/Bad Parse Tree
See examples above.
Expected Behavior/Parse Tree
The parse tree for something +x and something -y should be the same structure, minus the operator and name difference:
something + x should give a binary
something +x should give a unary
something+x should give a binary
Repro
something +x
something -y
Did you check existing issues?
Tree-Sitter CLI Version, if relevant (output of
tree-sitter --version)No response
Describe the bug
I'm working on an
ast-grepversion of the Rubocop ambiguous operator lint. One of the cases it needs to alert on issomething +xandsomething -y.When I do
something -yI get an AST like this:But when I do
something +xI get abinaryin the AST instead of aunaryas expected:Ruby alerts on both of these, showing that it parses both of these as a unary:
Steps To Reproduce/Bad Parse Tree
See examples above.
Expected Behavior/Parse Tree
The parse tree for
something +xandsomething -yshould be the same structure, minus the operator and name difference:something + xshould give abinarysomething +xshould give aunarysomething+xshould give abinaryRepro