mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 08:33:58 +02:00
[ruby/prism] Fix parser translator when splatting in pattern matching pin
Because it ends up treating it as a local variable, and `a.x`
is not a valid local variable name.
I'm not big on pattern matching, but conceptually it makes sense to me
to treat anything inside ^() to not be
pattern matching syntax?
80dbd85c45
This commit is contained in:
parent
fe9ebb2456
commit
334c261cc9
2 changed files with 6 additions and 1 deletions
|
@ -1481,7 +1481,8 @@ module Prism
|
|||
# foo => ^(bar)
|
||||
# ^^^^^^
|
||||
def visit_pinned_expression_node(node)
|
||||
expression = builder.begin(token(node.lparen_loc), visit(node.expression), token(node.rparen_loc))
|
||||
parts = node.expression.accept(copy_compiler(in_pattern: false)) # Don't treat * and similar as match_rest
|
||||
expression = builder.begin(token(node.lparen_loc), parts, token(node.rparen_loc))
|
||||
builder.pin(token(node.operator_loc), expression)
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue