Bug 23669 – [DIP1000] Compound assignment to length of slice member variable in scope method fails

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-02-04T04:59:37Z
Last change time
2023-02-17T16:28:01Z
Keywords
pull, rejects-valid
Assigned to
No Owner
Creator
Paul Backus

Comments

Comment #0 by snarwin+bugzilla — 2023-02-04T04:59:37Z
As of DMD 2.102.0, the following program fails to compile: --- struct S { string[] a; @safe void reserve() scope { a.length += 1; // error } } --- The error message is --- bug.d(6): Error: cannot take address of `scope` variable `this` since `scope` applies to first indirection only --- This error is both wrong and spurious: the address of `this` is not taken, and the program should compile successfully.
Comment #1 by snarwin+bugzilla — 2023-02-04T05:05:14Z
The error is caused by the way DMD lowers `a.length += 1;`, which can be seen using the -vcg-ast switch: --- (string[]* __arraylength2 = &this.a;) , _d_arraysetlengthT(*__arraylength2, (*__arraylength2).length + 1LU); ---
Comment #2 by dlang-bot — 2023-02-06T12:21:24Z
@ntrel created dlang/dmd pull request #14865 "Fix Issue 23669 - [DIP1000] Compound assignment to length of slice me…" fixing this issue: - Fix Issue 23669 - [DIP1000] Compound assignment to length of slice member variable in scope method fails https://github.com/dlang/dmd/pull/14865
Comment #3 by dlang-bot — 2023-02-17T16:28:01Z
dlang/dmd pull request #14865 "Fix Issue 23669 - [DIP1000] Compound assignment to length of slice me…" was merged into master: - 22c74814de7b19fcd92d22f73f093c22d53060dd by Nick Treleaven: Fix Issue 23669 - [DIP1000] Compound assignment to length of slice member variable in scope method fails https://github.com/dlang/dmd/pull/14865