From: "tompng (tomoya ishida)" Date: 2022-12-02T16:58:01+00:00 Subject: [ruby-core:111161] [Ruby master Bug#19175] Ripper does not recognize some pattern matching defining local variable Issue #19175 has been reported by tompng (tomoya ishida). ---------------------------------------- Bug #19175: Ripper does not recognize some pattern matching defining local variable https://bugs.ruby-lang.org/issues/19175 * Author: tompng (tomoya ishida) * Status: Open * Priority: Normal * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- Ripepr does not recognize hshptn and aryptn splat defining local variables. ~~~ruby 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)` I think `[:vcall, [:@ident, "x", [1, 11]]]` should be `[:var_ref, [:@ident, "x", [1, 11]]]` Other pattern seems to be OK. ~~~ruby 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]]]]] ~~~ -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/