[Issue 14769] New: Cannot instantiate templates for locally defined struct when constructor is present
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Jul 3 14:55:29 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14769
Issue ID: 14769
Summary: Cannot instantiate templates for locally defined
struct when constructor is present
Product: D
Version: D2
Hardware: x86_64
OS: Mac OS X
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: Sigurdhsson at gmail.com
The following fails to compile, with the error "Error: template std.conv.toImpl
cannot deduce function from argument types !(S2)(string)" (i.e. S1 works fine,
but S2 doesn't):
-----
import std.conv;
unittest {
struct S1 { public string a; }
struct S2 { public string a; this(string s) { a = s; } }
S1 s1 = to!S1("");
S2 s2 = to!S2(""); // <- ERROR
}
-----
Moving the struct definitions out of the unittest block also works fine:
-----
import std.conv;
struct S1 { public string a; }
struct S2 { public string a; this(string s) { a = s; } }
unittest {
S1 s1 = to!S1("");
S2 s2 = to!S2("");
}
-----
This is using DMD v2.067.
--
More information about the Digitalmars-d-bugs
mailing list