diff --git a/lib/prism/translation/parser/compiler.rb b/lib/prism/translation/parser/compiler.rb index acf4e77ee4..1beccc30a1 100644 --- a/lib/prism/translation/parser/compiler.rb +++ b/lib/prism/translation/parser/compiler.rb @@ -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 diff --git a/test/prism/fixtures/patterns.txt b/test/prism/fixtures/patterns.txt index 09584e43eb..449dac619b 100644 --- a/test/prism/fixtures/patterns.txt +++ b/test/prism/fixtures/patterns.txt @@ -218,3 +218,7 @@ a in b, and c a in b, or c (a in b,) and c (a in b,) or c + +x => ^([*a.x]) +x => ^([**a.x]) +x => ^({ a: })