Skip to content

Commit

Permalink
ambiguous: fix a rare case of comparison
Browse files Browse the repository at this point in the history
This used to do a weaker test than should have been required here. This
now aligns with the implementation in gf.c for the same fast path check.
  • Loading branch information
vtjnash committed Jan 9, 2023
1 parent 53a0a69 commit 72b73a4
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,9 @@ function isambiguous(m1::Method, m2::Method; ambiguous_bottom::Bool=false)
end
end
# if ml-matches reported the existence of an ambiguity over their
# intersection, see if both m1 and m2 may be involved in it
# intersection, see if both m1 and m2 seem to be involved in it
# (if one was fully dominated by a different method, we want to will
# report the other ambiguous pair)
have_m1 = have_m2 = false
for match in ms
match = match::Core.MethodMatch
Expand All @@ -1814,20 +1816,13 @@ function isambiguous(m1::Method, m2::Method; ambiguous_bottom::Bool=false)
minmax = m
end
end
if minmax === nothing
if minmax === nothing || minmax == m1 || minmax == m2
return true
end
for match in ms
m = match.method
m === minmax && continue
if match.fully_covers
if !morespecific(minmax.sig, m.sig)
return true
end
else
if morespecific(m.sig, minmax.sig)
return true
end
if !morespecific(minmax.sig, m.sig)
return true
end
end
return false
Expand All @@ -1842,12 +1837,12 @@ function isambiguous(m1::Method, m2::Method; ambiguous_bottom::Bool=false)
if ti2 <: m1.sig && ti2 <: m2.sig
ti = ti2
elseif ti != ti2
# TODO: this would be the correct way to handle this case, but
# TODO: this would be the more correct way to handle this case, but
# people complained so we don't do it
# inner(ti2) || return false
return false # report that the type system failed to decide if it was ambiguous by saying they definitely aren't
#inner(ti2) || return false # report that the type system failed to decide if it was ambiguous by saying they definitely are
return false # report that the type system failed to decide if it was ambiguous by saying they definitely are not
else
return false # report that the type system failed to decide if it was ambiguous by saying they definitely aren't
return false # report that the type system failed to decide if it was ambiguous by saying they definitely are not
end
end
inner(ti) || return false
Expand Down

0 comments on commit 72b73a4

Please sign in to comment.