StaticArrays.jl
StaticArrays.jl copied to clipboard
macros fail for static/mutable vector/matrix/array construction
M = 10
a = @SVector [1 for _ in 1:M] # working
put it in a function:
function test()
M = 10
a = @SVector [1 for _ in 1:M]
end
then it would throw error:
ERROR: LoadError: UndefVarError: `M` not defined
Stacktrace:
[1] top-level scope
@ none:1
[2] eval
@ Core .\boot.jl:383 [inlined]
[3] static_vector_gen(::Type{SVector}, ex::Any, mod::Module)
@ StaticArrays D:\Julia\.julia\packages\StaticArrays\EHHaF\src\SVector.jl:62
[4] var"@SVector"(__source__::LineNumberNode, __module__::Module, ex::Any)
@ StaticArrays D:\Julia\.julia\packages\StaticArrays\EHHaF\src\SVector.jl:152
in expression starting at D:\Project\Ali\test.jl:5
in expression starting at D:\Project\Ali\test.jl:2
@SVector, @SArray, @SMatrix, @MVector, @MArray, @MMatrix all behave the same.