Skip to content

Commit

Permalink
fix #27187, error in typeintersect of incompatible NamedTuples (#27191)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored May 22, 2018
1 parent 2f728b8 commit e655148
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions test/namedtuple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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{}

0 comments on commit e655148

Please sign in to comment.