@@ -176,15 +176,15 @@ end
176
176
function replace_enumerate! (q, prepreamble)
177
177
looprange = q. args[1 ]
178
178
if Meta. isexpr (looprange, :block )
179
- for i in 1 : length (looprange. args)
179
+ for i = 1 : length (looprange. args)
180
180
replace_single_enumerate! (q, prepreamble, i)
181
181
end
182
182
else
183
183
replace_single_enumerate! (q, prepreamble)
184
184
end
185
185
return q
186
186
end
187
- function replace_single_enumerate! (q, prepreamble, i= nothing )
187
+ function replace_single_enumerate! (q, prepreamble, i = nothing )
188
188
if isnothing (i) # not nest loop
189
189
looprange, body = q. args[1 ], q. args[2 ]
190
190
else # nest loop
@@ -203,7 +203,7 @@ function replace_single_enumerate!(q, prepreamble, i=nothing)
203
203
if Meta. isexpr (itersyms, :tuple , 2 )
204
204
indsym, varsym = itersyms. args[1 ]:: Symbol , itersyms. args[2 ]:: Symbol
205
205
_replace_looprange! (q, i, indsym, iter)
206
- pushfirst! (body. args, :($ varsym = $ iter[$ indsym + firstindex ($ iter) - 1 ]))
206
+ pushfirst! (body. args, :($ varsym = $ iter[$ indsym+ firstindex ($ iter)- 1 ]))
207
207
elseif Meta. isexpr (itersyms, :tuple , 1 ) # like `for (i,) in enumerate(...)`
208
208
indsym = itersyms. args[1 ]:: Symbol
209
209
_replace_looprange! (q, i, indsym, iter)
@@ -216,8 +216,10 @@ function replace_single_enumerate!(q, prepreamble, i=nothing)
216
216
end
217
217
return q
218
218
end
219
- _replace_looprange! (q, :: Nothing , indsym, iter) = q. args[1 ] = :($ indsym = Base. OneTo (length ($ iter)))
220
- _replace_looprange! (q, i:: Int , indsym, iter) = q. args[1 ]. args[i] = :($ indsym = Base. OneTo (length ($ iter)))
219
+ _replace_looprange! (q, :: Nothing , indsym, iter) =
220
+ q. args[1 ] = :($ indsym = Base. OneTo (length ($ iter)))
221
+ _replace_looprange! (q, i:: Int , indsym, iter) =
222
+ q. args[1 ]. args[i] = :($ indsym = Base. OneTo (length ($ iter)))
221
223
222
224
function turbo_macro (mod, src, q, args... )
223
225
q = macroexpand (mod, q)
0 commit comments