Project

General

Profile

Actions

Bug #20055

closed

Ripper seems to skip some checks like `void value expression` and `duplicated variable name`

Added by tompng (tomoya ishida) 5 months ago. Updated 2 months ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.3.0dev (2023-12-08T07:01:01Z master f2c84c4884) [x86_64-linux]
[ruby-core:115678]

Description

These are syntax error

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

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]]]]]]]

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #16008: Ripper hshptn node drops informationClosednobu (Nobuyoshi Nakada)Actions
Actions #1

Updated by nobu (Nobuyoshi Nakada) 5 months ago

  • Related to Bug #16008: Ripper hshptn node drops information added
Actions

Also available in: Atom PDF

Like0
Like0Like0