Skip to content

Commit

Permalink
Merge pull request #1 from ranocha/hr/test_pure_typeintersect
Browse files Browse the repository at this point in the history
add tests to the PR Mark typeintersect pure for Julia 1.9
  • Loading branch information
vchuravy authored Apr 26, 2023
2 parents 375dee8 + 96e0c22 commit 595b7d0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ else
const var"@_inline_meta" = Base.var"@inline"
end

# Julia 1.9 removed the `@pure` annotation in favor off Concrete-Eval
# Julia 1.9 removed the `@pure` annotation in favor of Concrete-Eval
# This behaves unfavorable with `julia --check-bounds=no`
Base.@pure function typeintersect(@nospecialize(a),@nospecialize(b))
Base.typeintersect(a,b)
Expand All @@ -19,7 +19,7 @@ TupleN{T,N} = NTuple{N,T}

# Base gives up on tuples for promote_eltype... (TODO can we improve Base?)
_TupleOf{T} = Tuple{T,Vararg{T}}
promote_tuple_eltype(::Union{_TupleOf{T}, Type{<:_TupleOf{T}}}) where {T} = T
promote_tuple_eltype(::Union{_TupleOf{T}, Type{<:_TupleOf{T}}}) where {T} = T
@generated function promote_tuple_eltype(::Union{T,Type{T}}) where T <: Tuple
t = Union{}
for i = 1:length(T.parameters)
Expand Down
16 changes: 16 additions & 0 deletions test/check_bounds_no.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module TestCheckBoundsNo

using Test
using StaticArrays

# https://github.com/JuliaArrays/StaticArrays.jl/issues/1155
@testset "Issue #1155" begin
u = @inferred(SVector(1, 2))
v = @inferred(SVector(3.0, 4.0))
a = 1.0
b = 2
result = @inferred(a * u + b * v)
@test result @inferred(SVector(7, 10))
end

end # module
7 changes: 7 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ if TEST_GROUP ∈ ["", "all", "group-A"]
addtests("inv.jl")
addtests("pinv.jl")
addtests("solve.jl")

# special logic required since we need to start a new
# Julia process for these tests
if isempty(enabled_tests) || "check_bounds_no" in enabled_tests
Random.seed!(42)
run(`$(Base.julia_cmd()) --check-bounds=no $(abspath("check_bounds_no.jl"))`)
end
end

if TEST_GROUP ["", "all", "group-B"]
Expand Down

0 comments on commit 595b7d0

Please sign in to comment.