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

incorrect ambiguity error #32703

Closed
JeffBezanson opened this issue Jul 26, 2019 · 0 comments · Fixed by #32731
Closed

incorrect ambiguity error #32703

JeffBezanson opened this issue Jul 26, 2019 · 0 comments · Fixed by #32731
Assignees
Labels
regression Regression in behavior compared to a previous version types and dispatch Types, subtyping and method dispatch

Comments

@JeffBezanson
Copy link
Member

This is reduced from a failure in StrBase on backports-1.2.0:

struct Str{C} <: AbstractString
end
	 
struct CSE{X}
end

UTF16CSE = CSE{1}
UTF16Str = Str{UTF16CSE}

ASCIICSE = CSE{2}
ASCIIStr = Str{ASCIICSE}

conv(::Type{<:Str{UTF16CSE}}, str::AbstractString) = 42
conv(::Type{<:Str{C}}, str::Str{C}) where {C<:CSE} = str

conv(UTF16Str, ASCIIStr())
julia> conv(UTF16Str, ASCIIStr())
ERROR: MethodError: conv(::Type{Str{CSE{1}}}, ::Str{CSE{2}}) is ambiguous. Candidates:
  conv(::Type{#s1} where #s1<:Str{C}, str::Str{C}) where C<:CSE in Main at REPL[9]:1
  conv(::Type{#s1} where #s1<:Str{CSE{1}}, str::AbstractString) in Main at REPL[8]:1
Possible fix, define
  conv(::Type{#s1} where #s1<:Str{CSE{1}}, ::Str{CSE{1}})
Stacktrace:
 [1] top-level scope at REPL[10]:1

The methods are indeed ambiguous, but not at the arguments passed in this case. Works on 1.1.

@JeffBezanson JeffBezanson added regression Regression in behavior compared to a previous version types and dispatch Types, subtyping and method dispatch labels Jul 26, 2019
@JeffBezanson JeffBezanson added this to the 1.2 milestone Jul 26, 2019
@JeffBezanson JeffBezanson self-assigned this Jul 30, 2019
JeffBezanson added a commit that referenced this issue Jul 30, 2019
JeffBezanson added a commit that referenced this issue Jul 31, 2019
JeffBezanson added a commit that referenced this issue Aug 2, 2019
caused by 5283847
(cherry picked from commit dc0bf52)
JeffBezanson added a commit that referenced this issue Aug 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression Regression in behavior compared to a previous version types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant