D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6994 - Using explicit 'this' in template constraint causes an error
Summary: Using explicit 'this' in template constraint causes an error
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: patch, rejects-valid
Depends on:
Blocks:
 
Reported: 2011-11-23 00:29 UTC by Kenji Hara
Modified: 2011-11-24 00:01 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Kenji Hara 2011-11-23 00:29:54 UTC
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
}
Comment 1 Kenji Hara 2011-11-23 05:31:52 UTC
D2 patch:
https://github.com/D-Programming-Language/dmd/pull/524

Maybe D1 has same issue.