digitalmars.D.bugs - [Issue 14449] New: Cannot create structure with `inout` constructor
- via Digitalmars-d-bugs (46/46) Apr 15 2015 https://issues.dlang.org/show_bug.cgi?id=14449
https://issues.dlang.org/show_bug.cgi?id=14449 Issue ID: 14449 Summary: Cannot create structure with `inout` constructor at compile time Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: maximzms gmail.com In the following example `inout` constructor works for some types but fails for others. test.d: -------------------- struct Foo(T) { T[1] a; this(in T[] src) inout { a = src; } // <----- line 4 } enum fbool = Foo!bool([true]); // OK enum fint = Foo!int([1]); // OK enum flong = Foo!long([1]); // OK enum fchar = Foo!char(['1']); // OK enum fstring = Foo!string(["1"]); // Error enum ffloat = Foo!float([1]); // Error struct Boo { int a; } enum fstruct = Foo!Boo([Boo(1)]); // Error void main() {} -------------------- Output: -------------------- test.d(4): Error: array cast from const(string[]) to const(inout(string)[]) is not supported at compile time test.d(12): called from here: Foo(null).this(["1"]) test.d(4): Error: array cast from const(float[]) to const(inout(float)[]) is not supported at compile time test.d(13): called from here: Foo(nanF).this([1.00000F]) test.d(4): Error: array cast from const(Boo[]) to const(inout(Boo)[]) is not supported at compile time test.d(15): called from here: Foo(Boo(0)).this([Boo(1)]) -------------------- --
Apr 15 2015