diff --git a/src/subtype.c b/src/subtype.c index 624ecfc2e9b7b..264009aadf9b2 100644 --- a/src/subtype.c +++ b/src/subtype.c @@ -2056,11 +2056,15 @@ static jl_value_t *intersect(jl_value_t *x, jl_value_t *y, jl_stenv_t *e, int pa break; newparams[i] = ii; } - jl_value_t *res; - if (i < np) - res = jl_bottom_type; - else - res = jl_apply_type(xd->name->wrapper, newparams, np); + jl_value_t *res = jl_bottom_type; + if (i >= np) { + JL_TRY { + res = jl_apply_type(xd->name->wrapper, newparams, np); + } + JL_CATCH { + res = jl_bottom_type; + } + } JL_GC_POP(); return res; } diff --git a/test/namedtuple.jl b/test/namedtuple.jl index 9f09e28ab30bd..933914b6d4f92 100644 --- a/test/namedtuple.jl +++ b/test/namedtuple.jl @@ -232,3 +232,7 @@ end y = map(v -> (a=v.a, b=v.a + v.b), [(a=1, b=missing), (a=1, b=2)]) @test y isa Vector{NamedTuple{(:a,:b), T} where T<:Tuple} @test isequal(y, [(a=1, b=missing), (a=1, b=3)]) + +# issue #27187 +@test reduce(merge,[(a = 1, b = 2), (c = 3, d = 4)]) == (a = 1, b = 2, c = 3, d = 4) +@test typeintersect(NamedTuple{()}, NamedTuple{names, Tuple{Int,Int}} where names) == Union{}