[Issue 20876] generated constructor always inout regardless of ability of fields to use inout

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 10 22:51:05 UTC 2024


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

--- Comment #16 from Walter Bright <bugzilla at digitalmars.com> ---
If we add `const` to the first copy constructor:

  struct S {
    this(const ref S) { }
  }

it compiles without error.

It seems like a simple solution would be:

1. if all fields take a const argument, then generate a const copy constructor

2. if all fields take an immutable argument, then generate an immutable copy
constructor

3. otherwise, generate a mutable copy constructor

--


More information about the Digitalmars-d-bugs mailing list