[Issue 22107] New: [scope][dip1000] Can't .dup an array of structs with impure copy constructor

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jul 6 15:16:19 UTC 2021


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

          Issue ID: 22107
           Summary: [scope][dip1000] Can't .dup an array of structs with
                    impure copy constructor
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: druntime
          Assignee: nobody at puremagic.com
          Reporter: dlang-bugzilla at thecybershadow.net

Not sure if this is a druntime bug or a compiler bug:

//////////////// test.d ///////////////
@safe unittest
{
    static int i;
    @safe struct S
    {
        this(this) { i++; }
    }

    void fun(scope S[] values...) @safe
    {
        values.dup;
    }
}
///////////////////////////////////////

$ dmd -o- -unittest -preview=dip1000 test.d
test.d(11): Error: scope variable `values` assigned to non-scope parameter `a`
calling object.dup!(S).dup

--


More information about the Digitalmars-d-bugs mailing list