This is because Prism recovers from the syntax error. For example:
eval("1; 2; 9a; 3; 4; 5; 9b")
with Prism this will give:
(eval at test.rb:1):1: warning: possibly useless use of a literal in void context
(eval at test.rb:1):1: warning: possibly useless use of a literal in void context
(eval at test.rb:1):1: warning: possibly useless use of a literal in void context
(eval at test.rb:1):1: warning: possibly useless use of a literal in void context
(eval at test.rb:1):1: warning: possibly useless use of a literal in void context
(eval at test.rb:1):1: warning: possibly useless use of a literal in void context
(eval at test.rb:1):1: warning: possibly useless use of a literal in void context
test.rb:1:in 'Kernel#eval': (eval at test.rb:1):1: syntax errors found (SyntaxError)
> 1 | 1; 2; 9a; 3; 4; 5; 9b
| ^ unexpected local variable or method, expecting end-of-input
| ^ unexpected local variable or method, expecting end-of-input
from test.rb:1:in '<main>'
with parse.y this will give:
(eval at test.rb:1):1: warning: possibly useless use of a literal in void context
(eval at test.rb:1):1: warning: possibly useless use of a literal in void context
test.rb:1:in 'Kernel#eval': (eval at test.rb:1):1: syntax error, unexpected local variable or method, expecting end-of-input (SyntaxError)
1; 2; 9a; 3; 4; 5; 9b
^
from test.rb:1:in '<main>'
this is because parse.y is not recovering from this error. I would imagine when parse.y does recover from this error, it would have the same behavior.
So I'm not sure if this is wrong or not. @mame (Yusuke Endoh) what do you think?