-
-
Notifications
You must be signed in to change notification settings - Fork 609
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
[REG2.066] Issue 15422 - associative array of nested struct - crash on usage #5308
Conversation
On a nested struct, built-in generated equality (`tupleof` comparison), hashing (static `xtoHash` function), and assignment (implicitly added `opAssign`) should use its enclosing context identity.
| if (i == 2) tthis = ad.type.immutableOf(); | ||
| if (i == 3) tthis = ad.type.sharedOf(); | ||
| if (i == 4) tthis = ad.type.sharedConstOf(); | ||
| if (i == 5) break; |
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.
for (size_t i = 0; i < 5; i++) then turn this into a final switch statement?
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.
Not sure. When I wrote this code, I thought that other qualifiers (inout, inout const, shared inout etc) might need to be tested here.
|
What's the state of this? |
|
Please submit the hundreds of lines of reformatting and refactoring as a separate PR. |
If a struct is nested in a class, its `vthis` will be reference to the parent class, and struct default equality and hashing considers the parent class equality and hashing. Otherwise, the `vthis` will be typed as void*, and pointer equality and hashing is merely used.
|
Superseded by #5391. It also drops style changes. |
If a struct is nested in a class, its
vthiswill be reference to the parent class, and struct default equality and hashing considers the parent class equality and hashing.Otherwise, the
vthiswill be typed as void*, and pointer equality and hashing is merely used.The root problem is an incorrect type for the struct
vthisfield. It has been already filed as Issue 14442, so this PR fixes it, and then issue 15422 will be fixed naturally.