Skip to content

Commit 8aa1f46

Browse files
committed
Only unnest parser mlhs nodes when no rest argument is provided
``` (a,), = [] PARSER==================== s(:masgn, s(:mlhs, s(:mlhs, s(:lvasgn, :a))), s(:array)) PRISM==================== s(:masgn, s(:mlhs, s(:lvasgn, :a)), s(:array)) ```
1 parent 6f506e1 commit 8aa1f46

File tree

3 files changed

+64
-33
lines changed

3 files changed

+64
-33
lines changed

lib/prism/translation/parser/compiler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,7 @@ def visit_multi_target_node(node)
13131313
def visit_multi_write_node(node)
13141314
elements = multi_target_elements(node)
13151315

1316-
if elements.length == 1 && elements.first.is_a?(MultiTargetNode)
1316+
if elements.length == 1 && elements.first.is_a?(MultiTargetNode) && !node.rest
13171317
elements = multi_target_elements(elements.first)
13181318
end
13191319

test/prism/fixtures/variables.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,5 @@ Foo = 1, 2
4545
(a; b; c)
4646

4747
a, (b, c), d = []
48+
49+
(a,), = []

test/prism/snapshots/variables.txt

Lines changed: 61 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)