Macros understand getindex syntax for numbers but not end word and throw error.
julia> @which xdots[end]
ERROR: UndefVarError: end not defined
Stacktrace:
[1] top-level scope at none:0
julia> @which xdots[1]
getindex(A::Array, i1::Int64) in Base at array.jl:731
Lowering code already does this though, so the right way to fix this may be to do lowering first and then do the method lookup on whatever it gets lowered to. Could someone file an issue about this bug?
Yeah, that’s how it used to work, and in this case it might work, but lowering does lots of other things and often will expand out to more than one line of code. So we’ve settled on just implementing a small subset of the “helpful” lowering manually within the macro itself. I believe we do have Julia code somewhere in Base that does this part of the lowering transform, so we could probably easily perform it here, too.