Skip to content

Commit

Permalink
fix #32703, bad ambiguity error
Browse files Browse the repository at this point in the history
caused by 5283847
  • Loading branch information
JeffBezanson committed Jul 30, 2019
1 parent 442d159 commit ed3a0c8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -3032,6 +3032,14 @@ static jl_value_t *intersect_types(jl_value_t *x, jl_value_t *y, int emptiness_o
jl_stenv_t e;
if (obviously_disjoint(x, y, 0))
return jl_bottom_type;
if (jl_is_dispatch_tupletype(x) || jl_is_dispatch_tupletype(y)) {
if (jl_subtype(x, y))
return x;
else if (jl_subtype(y, x))
return y;
else
return jl_bottom_type;
}
init_stenv(&e, NULL, 0);
e.intersection = e.ignore_free = 1;
e.emptiness_only = emptiness_only;
Expand Down
16 changes: 16 additions & 0 deletions test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1632,3 +1632,19 @@ end
@testintersect(Tuple{Type{T} where T<:(S32488{Tuple{_A}, Int64, 1, _A} where _A), Tuple{Vararg{Int64, D}} where D},
Tuple{Type{S32488{S, T, N, L}}, Tuple{Vararg{T, L}}} where L where N where T where S,
Tuple{Type{S32488{Tuple{L},Int64,1,L}},Tuple{Vararg{Int64,L}}} where L)

# issue #32703
struct Str{C} <: AbstractString
end
struct CSE{X}
end
const UTF16CSE = CSE{1}
const UTF16Str = Str{UTF16CSE}
const ASCIIStr = Str{CSE{2}}
c32703(::Type{<:Str{UTF16CSE}}, str::AbstractString) = 42
c32703(::Type{<:Str{C}}, str::Str{C}) where {C<:CSE} = str

@testintersect(Tuple{Type{UTF16Str},ASCIIStr},
Tuple{Type{<:Str{C}}, Str{C}} where {C<:CSE},
Union{})
@test c32703(UTF16Str, ASCIIStr()) == 42

0 comments on commit ed3a0c8

Please sign in to comment.