diff --git a/src/jltypes.c b/src/jltypes.c index c4f5a1aff88bd..43171ee332e87 100644 --- a/src/jltypes.c +++ b/src/jltypes.c @@ -1326,8 +1326,15 @@ jl_value_t *normalize_unionalls(jl_value_t *t) u = (jl_unionall_t*)t; } - if (u->var->lb == u->var->ub || may_substitute_ub(body, u->var)) - t = jl_instantiate_unionall(u, u->var->ub); + if (u->var->lb == u->var->ub || may_substitute_ub(body, u->var)) { + JL_TRY { + t = jl_instantiate_unionall(u, u->var->ub); + } + JL_CATCH { + // just skip normalization + // (may happen for bounds inconsistent with the wrapper's bounds) + } + } } JL_GC_POP(); return t; diff --git a/test/core.jl b/test/core.jl index 56ddfb42e10f1..74edc7cddf7f4 100644 --- a/test/core.jl +++ b/test/core.jl @@ -7584,3 +7584,6 @@ let S = Tuple{Tuple{Tuple{K, UInt128} where K<:Tuple{Int64}, Int64}}, @test pointer_from_objref(T) === pointer_from_objref(S) @test isbitstype(T) end + +# avoid impossible normalization (don't try to form Tuple{Complex{String}} here) +@test Tuple{Complex{T} where String<:T<:String} == Tuple{Complex{T} where String<:T<:String}