www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2157] New: mixin struct, function overload

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

           Summary: mixin struct, function overload
           Product: D
           Version: 2.013
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: someanon yahoo.com


$ dmd mixinstruct.d 
mixinstruct.d(15): function mixinstruct.S.attr (int) does not match parameter
types ()
mixinstruct.d(15): Error: s.attr can only be called on a mutable object, not
const(S)
mixinstruct.d(15): Error: expected 1 arguments, not 0
mixinstruct.d(15): Error: expression s.attr() is void and has no value


$ cat mixinstruct.d 
==============================================================
template T() {
int m_attr;
const {int attr() {return m_attr;}}  // reader
}

struct S {
mixin T;
void attr(int n) {m_attr = n;}  // writer
}

int main() {
  const S s;
  int r;
  r = s.attr();  // why this resolve to the writer? but not the reader?

  return r;
}

==============================================================


-- 
Jun 20 2008
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2157


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com
           Keywords|                            |rejects-valid
         OS/Version|Linux                       |All




------- Comment #1 from smjg iname.com  2008-11-24 06:45 -------
On DMD 2.019 Windows, the errors are the same, except at line 14.


-- 
Nov 24 2008