@@ -1698,7 +1698,7 @@ class exports.Fun extends Node
16981698 if vr .isEmpty!
16991699 vr = Var scope .temporary \arg
17001700 else if vr .value is \..
1701- vr = Var o .ref = scope .reference !
1701+ vr = Var o .ref = scope .temporary !
17021702 else if vr not instanceof Var
17031703 unaries = []
17041704 while vr instanceof Unary
@@ -1977,7 +1977,7 @@ class exports.While extends Node
19771977 for node in @body ?.lines or [] then return node if node .getJump ctx
19781978
19791979 addBody : (@body ) ->
1980- @body = Block If @guard , body if @guard
1980+ @body = Block If @guard , @ body if @guard
19811981 [top ] = @body .lines
19821982 @body .lines.length = 0 if top ?verb is \continue and not top .label
19831983 this
@@ -2080,11 +2080,24 @@ class exports.For extends While
20802080 @item = Literal \.. if delete @ref
20812081 body = Block Call .let do
20822082 with []
2083- ..push Assign Var(that ), Literal \index if delete @index
2084- ..push Assign that , Literal \item if delete @item
2083+ ..push Assign Var(that ), Literal \index $$ if @index
2084+ ..push Assign that , Literal \item $$ if @item
20852085 body
2086+
20862087 super body
20872088
2089+ if @guard and @let and (@index or @item )
2090+ @body .lines[0 ].if .traverse-children !~>
2091+ if it instanceof Var
2092+ if @index and it .value is @index
2093+ it .value = \index $$
2094+ if @item and it .value is @item .value
2095+ it .value = \item $$
2096+ if @let
2097+ delete @index
2098+ delete @item
2099+ this
2100+
20882101 compileNode : (o ) ->
20892102 o .loop = true
20902103 temps = @temps = []
@@ -2141,8 +2154,8 @@ class exports.For extends While
21412154 if @let
21422155 @body .traverseChildren !->
21432156 switch it .value
2144- | \index => it .value = idx
2145- | \item => it .value = "#svar[#idx]"
2157+ | \index $$ => it .value = idx
2158+ | \item $$ => it .value = "#svar[#idx]"
21462159 else
21472160 @infuseIIFE !
21482161 o .indent += TAB
0 commit comments