Actions
Bug #19175
closedRipper does not recognize some pattern matching defining local variable
Description
Ripepr does not recognize hshptn and aryptn splat defining local variables.
Ripper.sexp('a in [*x]; x')
# =>
[:program,
[[:case, [:vcall, [:@ident, "a", [1, 0]]], [:in, [:aryptn, nil, nil, [:var_field, [:@ident, "x", [1, 7]]], nil], nil, nil]],
[:vcall, [:@ident, "x", [1, 11]]]]]
Ripper.sexp('a in {x:}; x')
# =>
[:program,
[[:case, [:vcall, [:@ident, "a", [1, 0]]], [:in, [:hshptn, nil, [[[:@label, "x:", [1, 6]], nil]], nil], nil, nil]],
[:vcall, [:@ident, "x", [1, 11]]]]]
RubyVM::AbstractSyntaxTree returns (LVAR@1:11-1:12 :x)
[:vcall, [:@ident, "x", [1, 11]]]
should be [:var_ref, [:@ident, "x", [1, 11]]]
Ripper cannot parse this syntax OK code because rippter thinks local variable x is not defined.
{x:10} in {x:}; x /2 #=> 5
Ripper.sexp '{x:10} in {x:}; x /2' #=> nil
Other pattern seems to be OK.
Ripper.sexp('a in [x, y => z]; x; y; z')
# =>
[:program,
[[:case,
[:vcall, [:@ident, "a", [1, 0]]],
[:in,
[:aryptn,
nil,
[[:var_field, [:@ident, "x", [1, 6]]],
[:binary, [:var_field, [:@ident, "y", [1, 9]]], :"=>", [:var_field, [:@ident, "z", [1, 14]]]]],
nil,
nil],
nil,
nil]],
[:var_ref, [:@ident, "x", [1, 18]]],
[:var_ref, [:@ident, "y", [1, 21]]],
[:var_ref, [:@ident, "z", [1, 24]]]]]
Actions
Like0
Like0Like0Like0