Skip to content

Commit 9415e90

Browse files
committed
Fix masgn with nested mlhs unparsing
Extracted from mbj#387
1 parent 315c6ec commit 9415e90

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

lib/unparser/emitter/masgn.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ class MASGN < self
1111
private
1212

1313
def dispatch
14-
visit(target)
14+
if target.children.one? && n_mlhs?(Util.one(target.children))
15+
visit(Util.one(target.children))
16+
write(',')
17+
else
18+
visit(target)
19+
end
20+
1521
write(' = ')
1622
visit(source)
1723
end

lib/unparser/node_helpers.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def n_range?(node)
6868
lambda
6969
lvar
7070
match_rest
71+
mlhs
7172
or
7273
pair
7374
rescue

test/corpus/semantic/masgn.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
(a,), = []
2+
((a,),), = []

0 commit comments

Comments
 (0)