[Issue 14449] New: Cannot create structure with `inout` constructor at compile time
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Apr 15 04:30:10 PDT 2015
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 at puremagic.com
Reporter: maximzms at 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)])
--------------------
--
More information about the Digitalmars-d-bugs
mailing list