digitalmars.D.bugs - [Issue 19763] New: Cannot construct immutable struct from pure
- d-bugmail puremagic.com (44/44) Mar 26 2019 https://issues.dlang.org/show_bug.cgi?id=19763
https://issues.dlang.org/show_bug.cgi?id=19763 Issue ID: 19763 Summary: Cannot construct immutable struct from pure mutable struct Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: doob me.com The following example fails to compile: struct Foo { const(char)* filename; this(const(char)*) pure { } } void main() { immutable a = Foo(null); } Error: cannot implicitly convert expression `Foo(null).this(null)` of type `Foo` to `immutable(Foo)` But this code compiles: struct Foo { const(char)* filename; this(const(char)*) pure { } } Foo newFoo() pure { return Foo(null); } void main() { immutable a = newFoo(); } Also if "const(char)* filename" is changed to "char* filename" the first example compiles. --
Mar 26 2019