Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Compiler/src/typelimits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ end
typea === typeb && return true
if typea isa PartialStruct
aty = widenconst(typea)
issimplertype(𝕃, aty, widenconst(typeb)) || return false
if typeb isa Const || typeb isa PartialStruct
@assert n_initialized(typea) ≤ n_initialized(typeb) "typeb ⊑ typea is assumed"
elseif typeb isa PartialStruct
Expand Down
22 changes: 22 additions & 0 deletions Compiler/test/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5250,6 +5250,22 @@ let 𝕃ᵢ = Compiler.fallback_lattice
@test t.fields == Any[Const(42), Int]
end

# issue #60715
let 𝕃 = Compiler.fallback_lattice
local fn, fn1, pn, pn1
F(n) = iszero(n) ? Union{} : Tuple{Int, Union{Int, F(n-1)}}
P(n) = (f = F(n); Compiler.PartialStruct(𝕃, f, [Const(0), fieldtype(f, 2)]))

n = 0
while Compiler.issimpleenoughtype(F(n+1))
n += 1
fn, fn1, pn, pn1 = F(n), F(n+1), P(n), P(n+1)
@test Compiler.:⊑(𝕃, pn, pn1)
end
@test !Compiler.issimplertype(𝕃, pn1, pn)
@test !isa(Compiler.tmerge(𝕃, pn, pn1), Compiler.PartialStruct)
end

foo_empty_vararg(i...) = i[2]
bar_empty_vararg(i) = foo_empty_vararg(10, 20, 30, i...)
@test bar_empty_vararg(Union{}[]) === 20
Expand Down Expand Up @@ -6736,4 +6752,10 @@ throwconditional(c, x) = c ? throw(x isa Int) : throw(x isa Float64)
throwconditional(c, x)
end == Bool

# issue #60715
let
f() = 1; f(_, x...) = (0, f(x...))
@test f(1, 2, 3) == (0, (0, (0, 1)))
end

end # module inference
Loading