-
Notifications
You must be signed in to change notification settings - Fork 172
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
Tests for partial overlap #8
Comments
This would make a good first bug. The idea would be to modify Bonus points would be to add some cases to show that inference holds back from decided types if there are more than one applicable impl. For example: impl<T: Foo> Marker<u32> for T and impl<T: Bar> Marker<i32> for T would result in ambiguity on |
@nikomatsakis I started working on this. First, I started with a I got more confident and created a
which failed because Then I "accidentally" started implementing support for Do you have any pointers here? |
@mrhota, you're right that negative reasoning is not well-supported right now, and the current forms for negation are going to be removed, in favor of a more general purpose system of negation. However, you should be able to add this test without using negation. @nikomatsakis's comment lays out one particular strategy for doing so. Did that comment make sense to you? |
@aturon after stepping away for a few days, I think I understand the second part of that comment better. I admit I'm rather out of my depth, but the code is pretty straightforward, so that helps! |
@nikomatsakis did I understand you right? Here is a test I came up with:
Unfortunately, when I load the program into chalki, it says |
@mikeyhew No, those impls actually overlap, because you can use two different impls to prove |
@withoutboats I'm confused. I thought the impls were supposed to overlap? Niko said to "check that we can prove |
@withoutboats @nikomatsakis Is this what you meant?
|
Niko spoke unprecisely when he said the two impls overlap. What he means is that if the parameter is not known, they both could apply. It was like this:
If These impls don't actually overlap, in the sense of the overlapping impl check, because the type parameter on |
Well, actually, due to RFC 1268, marker traits (those with zero items) are allowed to overlap. So that may be a bug that @mikeyhew has uncovered, actually. |
A little annoying for chalk since nearly all of our tests use marker traits. |
True. =) Maybe we should make marker traits more explicit with |
@withoutboats I agree with @nikomatsakis. One of the unresolved question on RFC 1268, anyway, is whether to use a |
We should add some tests for the scenario where there are two equally applicable impls (for marker traits). This ought to be supported by the codebase -- it should refuse to infer details from either one, but if there are multiple sets that match a single set of types, that's ok.
The text was updated successfully, but these errors were encountered: