-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Explicitly mark as unsupported instead of crashing mapping a parameter record type defined not in a namespace #5777
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
Conversation
}; | ||
|
||
auto foo1(P::C) -> void; | ||
auto foo2(P) -> void; |
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.
In each of these, you have this foo2
with a call. However, is it necessary for the test (it's not inside the namespace)? If not, I'd suggest removing it; I'm not clear it's testing distinct behavior. If so, please add a comment clarifying what it's doing.
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.
Or, if you mean to test behavior of a type that contains another type, maybe that should be a separate test to clarify what you're trying to test?
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.
Thanks, done.
I've changed this PR to be made of:
- First commit: Just adds tests that don't diagnose for
class
andstruct
and wrongly treat the outer record as a namespace. This can be a separate PR. - The rest fixes that and adds the tests that would have crashed without the fix.
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.
You've split tests. But I don't think you're addressing my question of what the test is achieving.
That is, why is "Pass outer class after passing inner class" an interesting thing to test, particularly when including all the SemIR for both calls? I agree that's what it does, but what is the test going to be testing that is meaningfully different? (if you just want to test passing the outer class that has a nested class, why not only test that and have less IR? why is "after" important?)
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.
To be clear, I'm asking you to comment your code.
// --- inner_and_outer_value_param_type.h | ||
|
||
class O { | ||
public: | ||
class C {}; | ||
}; | ||
|
||
auto foo1(O::C) -> void; | ||
auto foo2(O) -> void; |
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.
Can this same header be shared, rather than copying it?
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.
Done.
import Cpp library "inner_and_outer_value_param_type.h"; | ||
|
||
fn F() { | ||
//@dump-sem-ir-begin |
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.
Does the SemIR need to be captured for the first call? Will it differ from the above test?
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.
Done.
}; | ||
|
||
auto foo1(P::C) -> void; | ||
auto foo2(P) -> void; |
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.
You've split tests. But I don't think you're addressing my question of what the test is achieving.
That is, why is "Pass outer class after passing inner class" an interesting thing to test, particularly when including all the SemIR for both calls? I agree that's what it does, but what is the test going to be testing that is meaningfully different? (if you just want to test passing the outer class that has a nested class, why not only test that and have less IR? why is "after" important?)
// CHECK:STDERR: ^~~~~~~~ | ||
// CHECK:STDERR: | ||
Cpp.foo1({}); | ||
Cpp.foo2({}); |
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.
If you're just trying to verify that Cpp.O
is a type, maybe:
Cpp.foo2({}); | |
//@dump-sem-ir-begin | |
// Verify `O` is a valid type. | |
var x: Cpp.O; |
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.
Trying this out actually revealed another bug here, which I've sent a fix for in #5789.
I think it's better to fix that first.
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.
Done.
…other record type. The code assumes the outer record is a namespace.
…r record type defined not in a namespace Before this change we crash in this case. After this change we diagnose a TODO. Will add the missing support for this in a separate PR. Part of carbon-language#5533.
…ggers importing the record.
I believe I've addressed all comments. |
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.
Basically LG, see comment
// CHECK:STDERR: | ||
Cpp.foo({}); | ||
//@dump-sem-ir-begin | ||
var x: Cpp.O; |
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.
Since the second check (x: Cpp.O
) is no longer calling, I think it'd make sense to re-combine the two tests now. It just hadn't been clear to me what you intended to test before: if you were testing the type was usable post-Cpp.foo
, or if you were testing that a type containing a type could be used at all.
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.
Done.
Before this change we crash in this case when trying to use the outer type.
After this change we diagnose a TODO.
Will add the missing support for this in a separate PR.
Part of #5533.