[Issue 9361] Nasty bug and/or error message for template constaints using this

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jan 20 18:33:17 PST 2013


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



--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> 2013-01-20 18:33:09 PST ---
Reduced test case:

struct Unit(A)
{
    void butPleaseDontUseMe()()
    if (is(unitType!((this))))  // !
    {}

}
template isUnit(alias T) if ( is(T)) {}
template isUnit(alias T) if (!is(T)) {}
template unitType(alias T) if (isUnit!T) {}
void main()
{
    Unit!int u;
    u.butPleaseDontUseMe();     // crashes
}

====

I think the instantiation unitType!((this)) in the template constraint for
butPleaseDontUseMe template function should always fail, because the 'this'
symbol yet not has an actual entity while the constraint evaluation.

That means, the invocation of s.foo() should fail in following.

template Sym(alias A) { enum Sym = true; }
struct S {
    void foo()() if (Sym!(this)) {}
    // Sym!(this) always make an error, because
    // Sym template never be able to access
    // valid 'this' symbol.
}
void main() { S s; s.foo(); }

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