Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #27187, error in typeintersect of incompatible NamedTuples #27191

Merged
merged 1 commit into from
May 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/subtype.c
Original file line number Diff line number Diff line change
@@ -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;
}
4 changes: 4 additions & 0 deletions test/namedtuple.jl
Original file line number Diff line number Diff line change
@@ -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{}