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
pure -> immutable fixes #3085
pure -> immutable fixes #3085
Conversation
@@ -616,7 +616,7 @@ Expression *CallExp::implicitCastTo(Scope *sc, Type *t) | |||
* convert to immutable | |||
*/ | |||
if (f && f->isolateReturn() && | |||
type->immutableOf()->equals(t->immutableOf())) | |||
type->immutableOf()->equals(t)) |
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.
Beat me to it. :o)
That said, my fix was different. Are you sure the expressed goal of 'Avoid emitting CastExp' is still adequately met by the modified code?
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 now removed the code altogether, see next commit.
Anybody knows what's up with Darwin_32? (Edit: There was a transitory failure, see https://d.puremagic.com/test-results/pull.ghtml?projectid=1&runid=858475.) |
@andralex: That's the second part I was talking about before. |
Note: Without the |
Unittests lgtm. Compiler experts, please review, thanks! |
Regarding the tests: I find that squashing multiple failings tests into a single file using TEST_OUTPUT gets confusing rather quickly (e.g. like in |
As the person who wrote the initial code for the conversion to immutable, it's both encouraging and troubling that I no longer understand how it works! |
To: @klickverbot
Maybe the ICE is related to bug 11822, bug 11850, 11857? If so, it is timely fixed by #3081 in git-head. |
To fix issue 11503, we should disable immutable -> mutable conversion on pure return, but we should continue to enable mutable -> immutable conversion at the same place. So completely removing On the other hand, fixing 11503 would break currently implemented unique constructor feature (#1726) so that it relies on the possibility of immutable to mutable conversion on pure constructor. That's why I'm proposing DIP53 before fixing the bug. |
@9rnsr: Regarding Regarding unique constructors, all the current test cases still work. Specifically, I didn't touch the constructor conversion rules in If you think that this breaks valid code, could you please provide a test case? |
@yebblies: Better? ;) |
/* Avoid emitting CastExp for:
* T[] make() pure { ... }
* immutable T[] arr = make(); // unique return
*/ |
@9rnsr: Backed out the |
@klickverbot In past, if |
@9rnsr: Well, that test case certainly seems to pass now. ;) If there is a way that |
Why the unrelated commits? |
@MartinNowak: They are refactorings concerning same piece of code, and were made when I worked on the issue resp. add documentation to the original code in response to review comments. Just click on the individual commits to review them one by one. The changes are well-separated, so each commit itself should be almost trivial (except for the actual fixes, of course). I could of course submit a pull request for each, but they would be interdependent, just making life harder for everyone. Just throwing everything into a single commit with the message "Issue 11503 - immutable return value from pure function implicitly converts to mutable." would of course also be an option. ;P |
…nverts to mutable.
The pure -> immutable case is checked in implicitConvTo as well, and since it yields MATCHexact, the castTo() in Expression::implicitCastTo is a no-op anyway.
…cape analysis (immutability violation).
No functional change intended.
Ping? @MartinNowak: I separated out the one hardly related commit into #3149. If it helps review, I can also split it up even further, but using the commit view things should be fairly clear… |
Looks reasonable, but I didn't dig very deep into this. |
Sorry, I think that was a fluke. |
This pull request may have introduced a regression: |
This function is utterly baffling to me, especially how it swaps source and target around, swaps ta and tb around independently, arggh. The bug in it is it falsely returns |
@WalterBright: The code was originally written by Kenji – I just fixed some small bugs and made it moderately more legible. I'm having a quick look at the problem (and at cleaning up the source/target things) right now, though. |
@klickverbot much appreciated! |
@klickverbot thanks for taking a look. I wrote this: #7179 and it now passes the test suite and the regression, but I am not terribly happy with it. I'd like a more understandable solution. For one thing it needs better comments. |
https://d.puremagic.com/issues/show_bug.cgi?id=11503
https://d.puremagic.com/issues/show_bug.cgi?id=11909
The actual changes are in 3c0342e and ac4aed5, the rest are just cleanup commits.