[Issue 6994] New: Using explicit 'this' in template constraint causes an error

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 23 00:30:48 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6994

           Summary: Using explicit 'this' in template constraint causes an
                    error
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: k.hara.pg at gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2011-11-23 00:29:54 PST ---
struct Foo {

    T get(T)(){ return T.init; }

    T func1(T)()
    if (__traits(compiles, get!T()))
    { return get!T; }

    T func2(T)()
    if (__traits(compiles, this.get!T()))   // add explicit 'this'
    { return get!T; }
}
void main()
{
    Foo foo;
    foo.get!int();      // OK
    foo.func1!int();    // OK
    foo.func2!int();    // NG
}

-- 
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