-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add failing tests for exposing the value of .Self through an interface #5957
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
base: trunk
Are you sure you want to change the base?
Add failing tests for exposing the value of .Self through an interface #5957
Conversation
I got a bad feeling I am getting the typish levels wrong here after continuing to stare at things. |
f75b1f7
to
96a1ffd
Compare
Thanks for that review, I removed the bogus test, and I have added a bunch more tests of .Self that I was using to test #5966 while working on it. It would be good to make sure we agree they are all supposed to pass as written. |
38728ea
to
eecce58
Compare
eecce58
to
fd9072a
Compare
Updated the nesting tests with what we discovered in open discussion today. |
bump for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL
5758d72
to
cb85ed0
Compare
cb85ed0
to
afc3467
Compare
// Shows both `I(.Self)` are `I(T)`. | ||
// CHECK:STDERR: fail_todo_nested_period_self.carbon:[[@LINE+4]]:9: error: found cycle in facet type constraint for `.(I(T).A)` [FacetTypeConstraintCycle] | ||
// CHECK:STDERR: T as (I(T) where .A = (I(T) where .A = {} and .B = {})); | ||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
// CHECK:STDERR: | ||
T as (I(T) where .A = (I(T) where .A = {} and .B = {})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should actually be a cycle, but it's still being reported as one when I get .Self working more, so pointing this out to double check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree this is a false positive. I guess our cycle checking is incorrectly thinking the .A
nested inside the second where
is a rewrite for the outer .A
, or something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks. Some comments but nothing that needs another look I think.
// CHECK:STDERR: U as (I where .I1 = U); | ||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~ | ||
// CHECK:STDERR: | ||
U as (I where .I1 = U); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have tests of the opposite condition somewhere too?
U as (I where .I1 = .Self);
(U as type) as (I where .I1 = .Self);
// CHECK:STDERR: u.(I.G)(); | ||
// CHECK:STDERR: ^~~~~~~ | ||
// CHECK:STDERR: | ||
u.(I.G)(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to split this and the next line out from the file that contains the previous let declaration, so that we don't have a mixture of "should not fail but does" and "should fail and does" in the same file?
// Shows both `I(.Self)` are `I(T)`. | ||
// CHECK:STDERR: fail_todo_nested_period_self.carbon:[[@LINE+4]]:9: error: found cycle in facet type constraint for `.(I(T).A)` [FacetTypeConstraintCycle] | ||
// CHECK:STDERR: T as (I(T) where .A = (I(T) where .A = {} and .B = {})); | ||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
// CHECK:STDERR: | ||
T as (I(T) where .A = (I(T) where .A = {} and .B = {})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree this is a false positive. I guess our cycle checking is incorrectly thinking the .A
nested inside the second where
is a rewrite for the outer .A
, or something like that?
// TODO: Improved error: no member named `I1` in `T` of type `type`. | ||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this ought to be valid: because T
is a template parameter, we ought to defer the lookup until we have a non-template value for it.
We test using .Self in a generic parameter of an interface and as the value of an associated constant.