[Issue 9990] New: templates with function alias cause forward reference error
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Apr 25 04:43:52 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9990
Summary: templates with function alias cause forward reference
error
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: SebastianGraf at t-online.de
--- Comment #0 from Sebastian Graf <SebastianGraf at t-online.de> 2013-04-25 04:43:50 PDT ---
import std.stdio;
struct S { string field; }
auto initS() { return S("hi"); }
class C(alias init)
{
private S _s;
this() { _s = init(); }
auto createProxy()
{
struct Proxy
{
private S* s;
void print() { writeln(s.field); }
}
return Proxy(&_s);
}
}
// alias SC = C!(initS);
static assert(!is(typeof(C!(initS))));
void main()
{
alias SC = C!(initS);
auto c = new SC;
c.createProxy().print();
}
This prints out "hi". If I alias SC at the global level instead, I get a
compiler error:
hi.d(24): Error: template instance hi.C!(initS) forward reference of function
initS
Line 24 is the line with the offending global alias. I think the global version
should also compile.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list