[Issue 7805] New: "static" allows free templated functions to accept	struct fields as template alias parameters
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Sat Mar 31 07:20:19 PDT 2012
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=7805
           Summary: "static" allows free templated functions to accept
                    struct fields as template alias parameters
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: thecybershadow at gmail.com
--- Comment #0 from Vladimir Panteleev <thecybershadow at gmail.com> 2012-03-31 07:20:50 PDT ---
//static
string f(alias X)()
{
    return null;
}
struct S
{
    int i;
    mixin(f!i());
}
This program doesn't compile, however uncommenting "static" makes it work.
DMD 2.058 produces this error message:
test.d(8): Error: struct test.S no size yet for forward reference
DMD git produces a different error message:
test.d(2): Error: function test.S.f!(i).f need 'this' to access member f
Note that fixing this issue by making both cases fail to compile would break
code. I believe the Orange serialization library uses this trick to stringify
field names with minimal syntax overhead.
-- 
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