Skip to content

Commit ed92217

Browse files
vchuravyranocha
andauthored
Mark typeintersect pure for Julia 1.9 (#1156)
* Mark typeintersect pure for Julia 1.9+ * add tests * fix typo * bump version * run CI on Julia v1.9 (including pre-releases) --------- Co-authored-by: Hendrik Ranocha <mail@ranocha.de>
1 parent 2f50491 commit ed92217

File tree

7 files changed

+36
-6
lines changed

7 files changed

+36
-6
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
matrix:
1515
version:
1616
- '1.6'
17+
- '~1.9.0-0'
1718
- '1'
1819
- 'nightly'
1920
os:

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "StaticArrays"
22
uuid = "90137ffa-7385-5640-81b9-e52037218182"
3-
version = "1.5.21"
3+
version = "1.5.22"
44

55
[deps]
66
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/arraymath.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@inline zeros(::Type{SA}) where {SA <: StaticArray{<:Tuple}} = zeros(Base.typeintersect(SA, AbstractArray{Float64}))
1+
@inline zeros(::Type{SA}) where {SA <: StaticArray{<:Tuple}} = zeros(typeintersect(SA, AbstractArray{Float64}))
22
@inline zeros(::Type{SA}) where {SA <: StaticArray{<:Tuple, T}} where T = _zeros(Size(SA), SA)
33
@generated function _zeros(::Size{s}, ::Type{SA}) where {s, SA <: StaticArray}
44
T = eltype(SA)
@@ -16,7 +16,7 @@
1616
end
1717
end
1818

19-
@inline ones(::Type{SA}) where {SA <: StaticArray{<:Tuple}} = ones(Base.typeintersect(SA, AbstractArray{Float64}))
19+
@inline ones(::Type{SA}) where {SA <: StaticArray{<:Tuple}} = ones(typeintersect(SA, AbstractArray{Float64}))
2020
@inline ones(::Type{SA}) where {SA <: StaticArray{<:Tuple, T}} where T = _ones(Size(SA), SA)
2121
@generated function _ones(::Size{s}, ::Type{SA}) where {s, SA <: StaticArray}
2222
T = eltype(SA)

src/convert.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function adapt_size(::Type{SA}, x) where {SA<:StaticArray}
112112
_no_precise_size(SA, x)
113113
end
114114
end
115-
SA′ = Base.typeintersect(SA, StaticArrayNoEltype{SZ,tuple_length(SZ)})
115+
SA′ = typeintersect(SA, StaticArrayNoEltype{SZ,tuple_length(SZ)})
116116
SA′ === Union{} && _no_precise_size(SA, x)
117117
return SA′
118118
end
@@ -139,7 +139,7 @@ function adapt_eltype(::Type{SA}, x) where {SA<:StaticArray}
139139
else
140140
eltype(x)
141141
end
142-
return Base.typeintersect(SA, AbstractArray{T})
142+
return typeintersect(SA, AbstractArray{T})
143143
end
144144

145145
need_rewrap(::Type{<:StaticArray}, x) = false

src/util.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ else
44
const var"@_inline_meta" = Base.var"@inline"
55
end
66

7+
# Julia 1.9 removed the `@pure` annotation in favor of Concrete-Eval
8+
# This behaves unfavorable with `julia --check-bounds=no`
9+
Base.@pure function typeintersect(@nospecialize(a),@nospecialize(b))
10+
Base.typeintersect(a,b)
11+
end
12+
713
# For convenience
814
TupleN{T,N} = NTuple{N,T}
915

@@ -13,7 +19,7 @@ TupleN{T,N} = NTuple{N,T}
1319

1420
# Base gives up on tuples for promote_eltype... (TODO can we improve Base?)
1521
_TupleOf{T} = Tuple{T,Vararg{T}}
16-
promote_tuple_eltype(::Union{_TupleOf{T}, Type{<:_TupleOf{T}}}) where {T} = T
22+
promote_tuple_eltype(::Union{_TupleOf{T}, Type{<:_TupleOf{T}}}) where {T} = T
1723
@generated function promote_tuple_eltype(::Union{T,Type{T}}) where T <: Tuple
1824
t = Union{}
1925
for i = 1:length(T.parameters)

test/check_bounds_no.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module TestCheckBoundsNo
2+
3+
using Test
4+
using StaticArrays
5+
6+
# https://github.com/JuliaArrays/StaticArrays.jl/issues/1155
7+
@testset "Issue #1155" begin
8+
u = @inferred(SVector(1, 2))
9+
v = @inferred(SVector(3.0, 4.0))
10+
a = 1.0
11+
b = 2
12+
result = @inferred(a * u + b * v)
13+
@test result @inferred(SVector(7, 10))
14+
end
15+
16+
end # module

test/runtests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ if TEST_GROUP ∈ ["", "all", "group-A"]
6666
addtests("inv.jl")
6767
addtests("pinv.jl")
6868
addtests("solve.jl")
69+
70+
# special logic required since we need to start a new
71+
# Julia process for these tests
72+
if isempty(enabled_tests) || "check_bounds_no" in enabled_tests
73+
Random.seed!(42)
74+
run(`$(Base.julia_cmd()) --check-bounds=no $(abspath("check_bounds_no.jl"))`)
75+
end
6976
end
7077

7178
if TEST_GROUP ["", "all", "group-B"]

0 commit comments

Comments
 (0)