dmd
dmd copied to clipboard
Fix Issue 22536 - CTFE: Missing destruction of array literal argument for scope slice parameter
It appears that CTFE does not know how to destroy array literal temporaries that are put on stack. My solution first collects the temporary destructors that are created here [1] and interprets them after the function call was interpreted.
[1] https://github.com/dlang/dmd/blob/master/src/dmd/expressionsem.d#L2074
Thanks for your pull request and interest in making D better, @RazvanN7! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Please verify that your PR follows this checklist:
- My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
- My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
- I have provided a detailed rationale explaining my changes
- New or modified functions have Ddoc comments (with
Params:andReturns:)
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
| Auto-close | Bugzilla | Severity | Description |
|---|---|---|---|
| ✓ | 22536 | blocker | CTFE: Missing destruction of array literal argument for scope slice parameter |
⚠️⚠️⚠️ Warnings ⚠️⚠️⚠️
- Regression or critical bug fixes should always target the
stablebranch. Learn more about rebasing tostableor the D release process.
To target stable perform these two steps:
- Rebase your branch to
upstream/stable:
git rebase --onto upstream/stable upstream/master
Testing this PR locally
If you don't have a local development environment setup, you can use Digger to test this PR:
dub run digger -- build "master + dmd#13496"
cc @kinke as this is blocking a fix of yours.
Related issue with -preview=in that ~~might be~~ is fixed by this patch:
int previewIn()
{
int numDtor;
struct S
{
int x;
~this() { ++numDtor; }
}
static accept(in S s) {}
accept(S(1));
return numDtor;
}
static assert(previewIn() == 1);
@MoonlightSentinel is this addition acceptable?
@MoonlightSentinel Done.
@MoonlightSentinel I have addressed your review.