Skip to content

Commit 0824c1b

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 38418ad commit 0824c1b

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
@@ -1326,8 +1326,15 @@ jl_value_t *normalize_unionalls(jl_value_t *t)
13261326
u = (jl_unionall_t*)t;
13271327
}
13281328

1329-
if (u->var->lb == u->var->ub || may_substitute_ub(body, u->var))
1330-
t = jl_instantiate_unionall(u, u->var->ub);
1329+
if (u->var->lb == u->var->ub || may_substitute_ub(body, u->var)) {
1330+
JL_TRY {
1331+
t = jl_instantiate_unionall(u, u->var->ub);
1332+
}
1333+
JL_CATCH {
1334+
// just skip normalization
1335+
// (may happen for bounds inconsistent with the wrapper's bounds)
1336+
}
1337+
}
13311338
}
13321339
JL_GC_POP();
13331340
return t;

test/core.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7584,3 +7584,6 @@ let S = Tuple{Tuple{Tuple{K, UInt128} where K<:Tuple{Int64}, Int64}},
75847584
@test pointer_from_objref(T) === pointer_from_objref(S)
75857585
@test isbitstype(T)
75867586
end
7587+
7588+
# avoid impossible normalization (don't try to form Tuple{Complex{String}} here)
7589+
@test Tuple{Complex{T} where String<:T<:String} == Tuple{Complex{T} where String<:T<:String}

0 commit comments

Comments
 (0)