Summary: Wrong type of implicit 'this' in struct/class
           Product: D
           Version: D2
          Platform: x86
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from Shin Fujishiro <> 2010-10-12 15:28:10 PDT 
Implicit 'this' references in struct/class templates are wrongly typed under
certain circumstance and the following code doesn't compile.
void main()
    auto va = S!("", int)();
    auto vb = makeS!("", int)();

struct S(alias p, T)
    T s;
    T fun() { return s; }   // (10)

S!(p, T) makeS(alias p, T)()
    return typeof(return)();
% dmd -o- -c test.d
test.d(10): Error: this for s needs to be type S not type S!("",int)

The error does not happen if

- Either va or vb is commented out,
- Template parameter "alias p" is replaced with "string p", or
- "return s" at line (10) is replaced with "return this.s".

The Sequence struct in std.range hits this problem. It currently works around
the problem by supplying explicit 'this' to all fields.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to