@@ -349,11 +349,13 @@ Statement = Transformer({
349349 if " comprehension" == _exp_0 then
350350 local first_name = names [1 ]
351351 local a = Accumulator (first_name )
352- node = self .transform .statement (first_value , function (exp )
352+ local action
353+ action = function (exp )
353354 return a :mutate_body ({
354355 exp
355356 })
356- end )
357+ end
358+ node = self .transform .statement (first_value , action , node )
357359 return a :wrap (node , " group" )
358360 end
359361 end
@@ -585,9 +587,9 @@ Statement = Transformer({
585587 wrapped = build .group ({
586588 build .declare ({
587589 names = (function ()
590+ local _list_0 = stm [2 ]
588591 local _accum_0 = { }
589592 local _len_0 = 1
590- local _list_0 = stm [2 ]
591593 for _index_0 = 1 , # _list_0 do
592594 local name = _list_0 [_index_0 ]
593595 if type (name ) == " string" then
@@ -699,7 +701,7 @@ Statement = Transformer({
699701 end )()
700702 })
701703 end ,
702- foreach = function (self , node )
704+ foreach = function (self , node , _ , parent_assign )
703705 smart_node (node )
704706 local source = unpack (node .iter )
705707 local destructures = { }
@@ -727,7 +729,11 @@ Statement = Transformer({
727729 if ntype (source ) == " unpack" then
728730 local list = source [2 ]
729731 local index_name = NameProxy (" index" )
730- local list_name = self :is_local (list ) and list or NameProxy (" list" )
732+ local assign_name
733+ if parent_assign then
734+ assign_name = parent_assign [2 ][1 ]
735+ end
736+ local list_name = assign_name ~= list and self :is_local (list ) and list or NameProxy (" list" )
731737 local slice_var = nil
732738 local bounds
733739 if is_slice (list ) then
@@ -768,7 +774,7 @@ Statement = Transformer({
768774 }
769775 }
770776 end
771- return build .group ({
777+ local out = build .group ({
772778 list_name ~= list and build .assign_one (list_name , list ) or NOOP ,
773779 slice_var or NOOP ,
774780 build [" for" ]({
@@ -786,6 +792,8 @@ Statement = Transformer({
786792 }
787793 })
788794 })
795+ out .has_unpack_copy = true
796+ return out
789797 end
790798 node .body = with_continue_listener (node .body )
791799 end ,
@@ -1085,9 +1093,9 @@ Statement = Transformer({
10851093 end
10861094 return self :set (" super" , function (block , chain )
10871095 if chain then
1096+ local _list_0 = chain
10881097 local slice = { }
10891098 local _len_0 = 1
1090- local _list_0 = chain
10911099 for _index_0 = 3 , # _list_0 do
10921100 local item = _list_0 [_index_0 ]
10931101 slice [_len_0 ] = item
@@ -1244,7 +1252,16 @@ do
12441252 if group_type == nil then
12451253 group_type = " block_exp"
12461254 end
1255+ local copy_list
1256+ if rawget (node , " has_unpack_copy" ) then
1257+ do
1258+ local _with_0 = node [2 ][1 ]
1259+ node [2 ][1 ] = NOOP
1260+ copy_list = _with_0
1261+ end
1262+ end
12471263 return build [group_type ]({
1264+ copy_list or NOOP ,
12481265 build .assign_one (self .accum_name , build .table ()),
12491266 build .assign_one (self .len_name , 1 ),
12501267 node ,
0 commit comments