Issue #20055 has been reported by tompng (tomoya ishida).
----------------------------------------
Bug #20055: Ripper seems to skip some checks like `void value expression` and `duplicated
variable name`
https://bugs.ruby-lang.org/issues/20055
* Author: tompng (tomoya ishida)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.3.0dev (2023-12-08T07:01:01Z master f2c84c4884) [x86_64-linux]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
These are syntax error
~~~ruby
return + return # void value expression
1 in [a, a] # duplicated variable name
1 + (1 => [a, a]) # both
~~~
But Ripper.sexp returns S-expression, not nil
~~~ruby
Ripper.sexp 'return + return'
# =>
[:program, [[:return, [:args_add_block, [[:unary, :+@, [:return0]]], false]]]]
Ripper.sexp '1 in [a, a]'
# =>
[:program, [[:case, [:@int, "1", [1, 0]], [:in, [:aryptn, nil, [[:var_field,
[:@ident, "a", [1, 6]]], [:var_field, [:@ident, "a", [1, 9]]]], nil,
nil], nil, nil]]]]
Ripper.sexp '1 + (1 => [a, a]) # both'
# =>
[:program, [[:binary, [:@int, "1", [1, 0]], :+, [:paren, [[:case, [:@int,
"1", [1, 5]], [:in, [:aryptn, nil, [[:var_field, [:@ident, "a", [1,
11]]], [:var_field, [:@ident, "a", [1, 14]]]], nil, nil], nil, nil]]]]]]]
~~~
--
https://bugs.ruby-lang.org/