www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23669] New: [DIP1000] Compound assignment to length of slice

https://issues.dlang.org/show_bug.cgi?id=23669

          Issue ID: 23669
           Summary: [DIP1000] Compound assignment to length of slice
                    member variable in scope method fails
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: snarwin+bugzilla gmail.com

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.

--
Feb 03 2023