-
-
Notifications
You must be signed in to change notification settings - Fork 610
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
Regression fix Issue 11591 - std.typecons.Tuple -s with classes fails at runtime as associative array keys #3054
Conversation
|
Why do AAs need opCmp? |
|
For historical reasons they use opCmp instead of opEquals. |
|
Why don't we fix that instead? |
|
Because 1) I don't want to break anything with this release and 2) that just pushes the problem to being an unsuitable opEquals() |
|
Needs this Phobos pull: dlang/phobos#1827 |
|
|
… as associative array keys
|
BTW, all the issues uncovered by this PR are variations on bug 11591 - the compiler accepting invalid code. The AA's would fail at runtime, but they didn't in these cases because either the AA was never actually used, or was used only in trivial cases. I think it's a good sign this PR is uncovering latent bugs. |
|
It's going to break code that works, because of a historical requirement of AAs that we don't need any more. Code I have uses AA literals to create AAs, and never modifies them, and I assume this will break it. In what cases does the compiler not generate a suitable opEquals? |
|
The same cases for which a suitable opCmp is not generated - when an opEquals is supplied, but does not match the required type signature. Look through the source for xerreq.
The code does not work - code that used it was never run. It would have issued a runtime error if it had. |
|
This is fix for Issue 11590 - [AA] Associative arrays should reject uncomparable types, not Issue 11591. |
|
Also there are Issue 11588 and Issue 11589. |
|
It fixes 11591. |
Regression fix Issue 11591 - std.typecons.Tuple -s with classes fails at runtime as associative array keys
Regression fix Issue 11591 - std.typecons.Tuple -s with classes fails at runtime as associative array keys
|
Note that this broke code, see http://www.reddit.com/r/programming/comments/1ytfc5/d_2065_released_with_396_fixes_and_improvements/cfnmkih |
This pushes a runtime error to a compile time error. It therefore has the potential to break existing code, but I suspect any such code was already broken (like the test12.d test case, see below).
The new error message also helpfully gives the correct form for the required opCmp function.
https://d.puremagic.com/issues/show_bug.cgi?id=11591