JuliaArrays / JuliaArrays/StaticArrays.jl
macros fail for static/mutable vector/matrix/array construction
Open
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 844
- Forks
- 159
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 3
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the function example with @SVector, @SArray, @SMatrix, @MVector, @MArray, and @MMatrix, then inspect the macro implementations, including static_vector_gen in src/SVector.jl. Done means construction with a local M works inside a function for all six macros without the reported UndefVarError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100