www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20942] New: [DMD HEAD] Unable to append a postblit disabled

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

          Issue ID: 20942
           Summary: [DMD HEAD] Unable to append a postblit disabled struct
                    to a dynamic array
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: puneet coverify.org

$ /tmp/dmd2/linux/bin64/dmd -version=BUG foo.d
foo.d(16): Error: struct foo.Foo is not copyable because it is annotated with
 disable
$ cat foo.d
struct Foo {
  version(BUG) {
     disable this(this);
  }
  this(ref inout(Foo) other) {
    import std.stdio;
    writeln("Copy Construtor");
  }
}
void main() {
  Foo d;
  Foo e = d;                    // copy -- no issue
  Foo[] foos;
  // foos.length = foos.length + 1;
  // foos[$-1] = d;             // opAssign into array element -- no issue
  foos ~= d;                    // <<<<<< does not compile
}

--
Jun 17 2020