www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5046] New: Wrong type of implicit 'this' in struct/class templates

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5046

           Summary: Wrong type of implicit 'this' in struct/class
                    templates
           Product: D
           Version: D2
          Platform: x86
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: rsinfu gmail.com



---
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: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 12 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5046


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |k.hara.pg gmail.com



https://github.com/D-Programming-Language/dmd/pull/94

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 14 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5046


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



20:17:45 PDT ---
https://github.com/D-Programming-Language/dmd/commit/d3c324c8b1290c84e4808f9ac040e70a3e27b7f6

https://github.com/D-Programming-Language/dmd/commit/ca51706314e24b1b65a0417fb6529074ef988727

https://github.com/D-Programming-Language/dmd/commit/6052888a19f0dc048c2aae07d03d5b239b0901ff

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 18 2011