Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macros fail for static/mutable vector/matrix/array construction #1252

Open
ErikQQY opened this issue Apr 12, 2024 · 0 comments
Open

macros fail for static/mutable vector/matrix/array construction #1252

ErikQQY opened this issue Apr 12, 2024 · 0 comments

Comments

@ErikQQY
Copy link

ErikQQY commented Apr 12, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant