-
-
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
Fix Issue 13667 - ICE: stack overflow using self-referencing cast ins… #12168
Conversation
|
Thanks for your pull request and interest in making D better, @BorisCarvajal! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla references
|
|
Please target stable, otherwise LGTM. |
|
Can it be merged to master? Another |
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.
Please don't mix refactoring with bug fixes. First do one, then the other.
src/dmd/dcast.d
Outdated
| @@ -1508,6 +1487,32 @@ Expression castTo(Expression e, Scope* sc, Type t) | |||
| this.t = t; | |||
| } | |||
|
|
|||
| // Try casting the alias this member. Return the expression if it succeeds, null otherwise. | |||
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.
What are tob and t1b ?
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.
Am I correct that moving tryAliasThisCast here was just a refactoring, and not part of the fix? If so, refactorings (no matter how tempting) should go in separate PRs.
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.
It is a refactoring, but it also adds some 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.
But you are right, the refactoring does make it difficult to spot the added bits.
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.
Yep sorry, I've separated refactoring and fix in two commits. It looks more clear now.
src/dmd/dcast.d
Outdated
| if (att1 && t1b.equivalent(att1)) | ||
| return null; | ||
| else if (!att1 && t1b.checkAliasThisRec()) | ||
| att1 = t1b; |
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.
@WalterBright Lines 1501-1504 were not previously in this function.
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.
These are the check needed before any alias this resolving to avoid infinite recursion.
8f15d72 to
28611a3
Compare
|
Bug fixes and refactorings should be in separate PRs, not just separate commits. The reason is so they can be reviewed independently on their merits, as well as the usual if one introduces a regression, it doesn't implicate the other. I remember a PR from a few years ago that was shown to be responsible for a regression. The code was around 250 lines of complicated refactoring, and one line of bug fix. It took me a long time to figure that out. |
|
Ok |
|
Refactoring -> #12180 |
|
Rebase and we're good to go. |
…ide recursive alias this method
28611a3 to
2c436fe
Compare
|
@WalterBright Do you have any other objections on this PR? |
…ide recursive alias this method