From 78c5002534c591eaea68f1ef3f1580401e9bcd1e Mon Sep 17 00:00:00 2001 From: John Cobbler <44442232+JohnCobbler@users.noreply.github.com> Date: Sat, 25 Jul 2026 14:18:53 +0000 Subject: [PATCH 1/3] Report element count in generator-too-short error (#1207) The error printed the failing CartesianIndex coordinate instead of the number of elements produced, so a one-short generator of length 5 reported "stopped at 5" even though only 4 values were produced. Report LinearIndices(inds)[i]-1 as the count. Remove unused shape_string(::CartesianIndex). Tests use occursin for Julia 1.6 compat. --- src/SArray.jl | 4 ++-- test/SArray.jl | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/SArray.jl b/src/SArray.jl index 8f02e256..925fefd1 100644 --- a/src/SArray.jl +++ b/src/SArray.jl @@ -1,13 +1,13 @@ @noinline function generator_too_short_error(inds::CartesianIndices, i::CartesianIndex) - error("Generator produced too few elements: Expected exactly $(shape_string(inds)) elements, but generator stopped at $(shape_string(i))") + n = LinearIndices(inds)[i] - 1 + error("Generator produced too few elements: Expected exactly $(shape_string(inds)) elements, but got $(n)") end @noinline function generator_too_long_error(inds::CartesianIndices) error("Generator produced too many elements: Expected exactly $(shape_string(inds)) elements, but generator yields more") end shape_string(inds::CartesianIndices) = join(length.(inds.indices), '×') -shape_string(inds::CartesianIndex) = join(Tuple(inds), '×') @inline throw_if_nothing(x, inds, i) = (x === nothing && generator_too_short_error(inds, i); x) diff --git a/test/SArray.jl b/test/SArray.jl index d530efd1..1f581c9d 100644 --- a/test/SArray.jl +++ b/test/SArray.jl @@ -43,6 +43,39 @@ @test_throws Exception SArray{Tuple{2,3}}(10i+j for i in 1:1, j in 1:3) @test_throws Exception SArray{Tuple{2,3}}(10i+j for i in 1:3, j in 1:3) + # too-short error reports the count produced, not the failing coordinate (#1207) + # (@test_throws "msg" needs Julia 1.8+; package supports 1.6) + let err = try + SVector{5}(i for i in 1:5 if i != 2) + catch e + e + end + @test err isa Exception + msg = sprint(showerror, err) + @test occursin("Expected exactly 5 elements", msg) + @test occursin("got 4", msg) + @test !occursin("stopped at", msg) + end + let err = try + SMatrix{2,3}(i for i in 1:6 if i != 4) + catch e + e + end + @test err isa Exception + msg = sprint(showerror, err) + @test occursin("Expected exactly 2×3 elements", msg) + @test occursin("got 5", msg) + end + let err = try + SVector{3}(i for i in 1:0) + catch e + e + end + @test err isa Exception + @test occursin("got 0", sprint(showerror, err)) + end + @test SVector{5}(i for i in 1:5) == SVector{5}(1, 2, 3, 4, 5) + @test StaticArrays.sacollect(SVector{6}, Iterators.product(1:2, 1:3)) == SVector{6}(collect(Iterators.product(1:2, 1:3))) @test StaticArrays.sacollect(SVector{2}, Iterators.zip(1:2, 2:3)) == From 4ecb0d842b2ce9da27b4669ec012090d28e8c4fd Mon Sep 17 00:00:00 2001 From: Mateusz Baran Date: Thu, 13 Aug 2026 15:00:43 +0200 Subject: [PATCH 2/3] disable a test failing due to a bug in LLVM --- test/expm.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/expm.jl b/test/expm.jl index 025c1bb9..cc2e1095 100644 --- a/test/expm.jl +++ b/test/expm.jl @@ -23,7 +23,12 @@ using StaticArrays, Test, LinearAlgebra for nB in (0.005, 0.1, 0.5, 3.0, 20.0) B = A*nB/nA SB = SMatrix{sz,sz,typ}(B) - @test exp(B) ≈ exp(SB) + if Sys.ARCH in (:x86_64, :i686) && VERSION >= v"1.12" && VERSION < v"1.13" && typ === ComplexF64 + # Julia 1.12 has a bug that makes this test fail on some systems, + # see https://github.com/JuliaLang/julia/issues/62368 + else + @test exp(B) ≈ exp(SB) + end end end end From fd8cb945c63c03d1ba0dc941b0180fad00b5885a Mon Sep 17 00:00:00 2001 From: Mateusz Baran Date: Fri, 14 Aug 2026 12:31:32 +0200 Subject: [PATCH 3/3] bump version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index ba8ee58d..d9fa7edc 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "StaticArrays" uuid = "90137ffa-7385-5640-81b9-e52037218182" -version = "1.9.18" +version = "1.9.19" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"