-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Type constraint ignored by typeintersect
and function ambiguity check
#11136
Comments
As mentioned in the mailing list thread,
|
Possibly related #8652 The following simplified version of the code from #8652 does not produce a warning when it should.... julia> type A; end
julia> f{T}(::T, ::T) = 1
f (generic function with 1 method)
julia> f{T}(::T, ::A) = 2
f (generic function with 2 methods) Edit: This bug is indeed a regression compare to |
Just for clarification, am I right that AFAICT, as long as the set of types either signature matches is not a subset of the other one and the two set also have common elements, the two method should be ambigious. If this is true, then since only Different from what is reported in #8652, the result from the example above seems to be the same indepent of the order the methods are defined though.... |
Yes, I think the second should be ambiguous and the first not. I'm still a little hazy on these things, though. While this doesn't answer the question of what's wrong, this gets at the internal machinations: julia> ams(a, b) = ccall(:jl_args_morespecific, Cint, (Any,Any), a, b)
ams (generic function with 1 method)
julia> T = TypeVar(:T, true)
T
julia> type A; end
julia> type B; end
julia> t1 = Tuple{T, A}
Tuple{T,A}
julia> t2 = Tuple{T, T}
Tuple{T,T}
julia> ams(t1,t2)
1
julia> ams(t2,t1)
0
julia> TB = TypeVar(:T, B, true)
T<:B
julia> t3 = Tuple{A, TB}
Tuple{A,T<:B}
julia> ams(t3,t2)
0
julia> ams(t2,t3)
0 |
IMHO, this is probably the reason (at some level) for #8652 and |
I haven't taken the time to check what's going on with |
That's the reason I mentioned |
The document doesn't say much about
|
Also should |
Ah, I hadn't noticed the non-commutivity, sorry for not reading carefully enough. (I should add: your bug reports and investigations of underlying causes---not to mention your fixes---are exemplary.) I'll bet that's the underlying issue. Yes,
I agree. Having finally gotten the hang of them in just the last couple of weeks myself, I'm in the middle of a pretty big documentation project. I was going to finish it in one monolithic go, but let me know if you want it sooner and I'll push some pieces. |
Non-commutative |
Jeff once commented in one of my issues that |
@mauro3 I think @timholy 's document on Edit: Ahh, yeah, he mentioned me but didn't refer to this PR so the PR for the doc didn't appear in the timeline of this PR. Anyway, here was the PR #11185 |
Cool! |
I wouldn't use TypeVars in actual code, but knowing a bit about them is irreplaceable if you want to, for example, isolate & fix bugs in the type system. |
The original problem the referenced email thread in this issue manifested itself when |
(I was going to wait for the original reporter to report it here but since I don't want to spam the mailing list with update of my minimum test case, I decided to report it here myself)
See the mailing list thread here
Minimum working example
Output after fixing the ambigious error output formatting.
The text was updated successfully, but these errors were encountered: