@@ -147,23 +147,13 @@ need_dynamic_optic(ex) =
147147replace_underscore (ex, to) = postwalk (x -> x === :_ ? to : x, ex)
148148
149149function lower_index (collection:: Symbol , index, dim)
150- index = MacroTools. replace (
151- index, :end ,
152- dim === nothing ? :($ (Base. lastindex)($ collection)) : :($ (Base. lastindex)($ collection, $ dim))
153- )
154- index = MacroTools. replace (
155- index, :begin ,
156- dim === nothing ? :($ (Base. firstindex)($ collection)) : :($ (Base. firstindex)($ collection, $ dim))
157- )
150+ lasti = dim === nothing ? :($ (Base. lastindex)($ collection)) : :($ (Base. lastindex)($ collection, $ dim))
151+ firsti = dim === nothing ? :($ (Base. firstindex)($ collection)) : :($ (Base. firstindex)($ collection, $ dim))
152+ index = MacroTools. replace (index, :end , lasti)
153+ index = MacroTools. replace (index, :begin , firsti)
158154 # New syntax for begin/end in indexing expression, see https://github.com/JuliaLang/julia/pull/57368
159- index = MacroTools. replace (
160- index, Expr (:end ),
161- dim === nothing ? :($ (Base. lastindex)($ collection)) : :($ (Base. lastindex)($ collection, $ dim))
162- )
163- index = MacroTools. replace (
164- index, Expr (:begin ),
165- dim === nothing ? :($ (Base. firstindex)($ collection)) : :($ (Base. firstindex)($ collection, $ dim))
166- )
155+ index = MacroTools. replace (index, Expr (:end ), lasti)
156+ index = MacroTools. replace (index, Expr (:begin ), firsti)
167157end
168158
169159_secondarg (_, x) = x
0 commit comments