Skip to content

Commit c92b559

Browse files
martinholtersKristofferC
authored andcommitted
Avoid impossible unionall normalization (#42003)
If the unionall bounds are inconsistent with the wrapper's bound, avoid throwing due to an impossible type instantiation. (cherry picked from commit b5b0684)
1 parent 7d1e1c3 commit c92b559

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/jltypes.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,8 +1200,15 @@ jl_value_t *normalize_unionalls(jl_value_t *t)
12001200
u = (jl_unionall_t*)t;
12011201
}
12021202

1203-
if (u->var->lb == u->var->ub || may_substitute_ub(body, u->var))
1204-
t = jl_instantiate_unionall(u, u->var->ub);
1203+
if (u->var->lb == u->var->ub || may_substitute_ub(body, u->var)) {
1204+
JL_TRY {
1205+
t = jl_instantiate_unionall(u, u->var->ub);
1206+
}
1207+
JL_CATCH {
1208+
// just skip normalization
1209+
// (may happen for bounds inconsistent with the wrapper's bounds)
1210+
}
1211+
}
12051212
}
12061213
JL_GC_POP();
12071214
return t;

test/core.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7549,3 +7549,6 @@ const T35130 = Tuple{Vector{Int}, <:Any}
75497549
end
75507550
h35130(x) = A35130(Any[x][1]::Vector{T35130})
75517551
@test h35130(T35130[([1],1)]) isa A35130
7552+
7553+
# avoid impossible normalization (don't try to form Tuple{Complex{String}} here)
7554+
@test Tuple{Complex{T} where String<:T<:String} == Tuple{Complex{T} where String<:T<:String}

0 commit comments

Comments
 (0)