-
Notifications
You must be signed in to change notification settings - Fork 65
Open
Labels
Description
Did you check existing issues?
- I have read all the tree-sitter docs if it relates to using the parser
- I have searched the existing issues of tree-sitter-c
Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)
No response
Describe the bug
The Tree-sitter Ruby parser accepts def f; return(1,2); end, whereas the official Ruby parser does not.
Steps To Reproduce/Bad Parse Tree
Use tree-sitter-parse
def f; return(1,2); end
(program [0, 0] - [1, 0]
(method [0, 0] - [0, 23]
name: (identifier [0, 4] - [0, 5])
body: (body_statement [0, 7] - [0, 19]
(return [0, 7] - [0, 18]
(argument_list [0, 13] - [0, 18]
(integer [0, 14] - [0, 15])
(integer [0, 16] - [0, 17]))))))
Expected Behavior/Parse Tree
Using tree-sitter parse on the provided example should fail. like that
$ irb
irb(main):001> def f;return(1,2); end
<internal:kernel>:168:in 'Kernel#loop': (irb):1: syntax errors found (SyntaxError)
> 1 | def f;return(1,2); end
| ^ expected a matching `)`
| ^ unexpected ',', ignoring it
| ^ unexpected ',', expecting end-of-input
| ^ unexpected ')', ignoring it
| ^ unexpected ')', expecting end-of-input
from /opt/local/lib/ruby3.4/gems/3.4.0/gems/irb-1.14.3/exe/irb:9:in '<top (required)>'
from /opt/local/bin/irb:25:in 'Kernel#load'
from /opt/local/bin/irb:25:in '<main>'