Skip to content

Commit

Permalink
Fix missing tuple wrapper in sacollect (JuliaArrays#1153)
Browse files Browse the repository at this point in the history
* Fix missing tuple wrapper in sacollect

* version bump

---------

Co-authored-by: Mateusz Baran <mateuszbaran89@gmail.com>
  • Loading branch information
aafsar and mateuszbaran authored Apr 15, 2023
1 parent f6e5db2 commit 1b5a994
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "StaticArrays"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.5.20"
version = "1.5.21"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
10 changes: 5 additions & 5 deletions src/SArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ shape_string(inds::CartesianIndex) = join(Tuple(inds), '×')
iter = :(iterate(gen,st))
end
push!(stmts, :($iter === nothing || generator_too_long_error($inds)))
push!(stmts, :(SA($(args...))))
push!(stmts, :(SA(($(args...),))))
Expr(:block, stmts...)
end
"""
Expand Down Expand Up @@ -92,7 +92,7 @@ function cat_any!(out, dims_before, dims_after, args::Vector{Any})
@views for arg in args
len = _cat_size(arg, catdim)
dest = out[dims_before..., i+1:i+len, dims_after...]
if arg isa AbstractArray
if arg isa AbstractArray
copyto!(dest, arg)
else
dest[] = arg
Expand Down Expand Up @@ -171,7 +171,7 @@ function static_array_gen(::Type{SA}, @nospecialize(ex), mod::Module) where {SA}
rngs = Any[Core.eval(mod, ex.args[i+1].args[2]) for i = 1:n_rng]
exprs = (:(f($(j...))) for j in Iterators.product(rngs...))
return quote
let
let
f($(escall(rng_args)...)) = $(esc(ex.args[1]))
$SA{$Tuple{$(size(exprs)...)}}($tuple($(exprs...)))
end
Expand All @@ -190,7 +190,7 @@ function static_array_gen(::Type{SA}, @nospecialize(ex), mod::Module) where {SA}
rngs = Any[Core.eval(mod, ex.args[i+1].args[2]) for i = 1:n_rng]
exprs = (:(f($(j...))) for j in Iterators.product(rngs...))
return quote
let
let
f($(escall(rng_args)...)) = $(esc(ex.args[1]))
$SA{$Tuple{$(size(exprs)...)},$T}($tuple($(exprs...)))
end
Expand Down Expand Up @@ -236,7 +236,7 @@ It supports:
2. comprehensions
!!! note
The range of a comprehension is evaluated at global scope by the macro, and must be
The range of a comprehension is evaluated at global scope by the macro, and must be
made of combinations of literal values, functions, or global variables.
3. initialization functions
Expand Down
1 change: 1 addition & 0 deletions test/SVector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
@test SVector{0,Int}().data === ()
@test SVector{3,Int}(i for i in 1:3).data === (1,2,3)
@test SVector{3,Float64}(i for i in 1:3).data === (1.0,2.0,3.0)
@test SVector{1}(SVector(SVector(1.0), SVector(2.0))[j] for j in 1:1) == SVector((SVector(1.0),))
@test_throws Exception SVector{3}(i for i in 1:2)
@test_throws Exception SVector{3}(i for i in 1:4)
@test_throws Exception SVector{3,Int}(i for i in 1:2)
Expand Down

0 comments on commit 1b5a994

Please sign in to comment.