www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 571] New: class instance member template returns strange value

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

           Summary: class instance member template returns strange value
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: lovesyao hotmail.com


class Test{
  template test(){
    const int test=1;
  }
}

void main(){
  assert(Test.test!()==1);//ok
  assert((new Test).test!()==1);//failed
}


-- 
Nov 18 2006
next sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

d-bugmail puremagic.com schrieb am 2006-11-19:
 http://d.puremagic.com/issues/show_bug.cgi?id=571

 class Test{
   template test(){
     const int test=1;
   }
 }

 void main(){
   assert(Test.test!()==1);//ok
   assert((new Test).test!()==1);//failed
 }

Added to DStress as http://dstress.kuehne.cn/run/t/template_47_A.d http://dstress.kuehne.cn/run/t/template_47_B.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFFaEqHLK5blCcjpWoRAgCJAJ9dZUpUeaSP0QBXBufU/RlYeYqjAwCglpP4 IY/UQZYAOBYmlU3lVwDvuCE= =pw18 -----END PGP SIGNATURE-----
Nov 25 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=571





------- Comment #2 from bugzilla digitalmars.com  2008-06-29 20:53 -------
This is invalid code in D 2.0, as templates cannot be used to add fields to a
class.


-- 
Jun 29 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=571





------- Comment #3 from 2korden gmail.com  2008-06-30 05:39 -------
Updated test case for D2:

class Test {
  template test(){
    enum int test = 1;  // replace with const for D1
  }
}

void main(){
  printf("%d", (new Test()).test!());
}


-- 
Jun 30 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=571


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #4 from bugzilla digitalmars.com  2008-07-09 22:36 -------
Fixed dmd 1.032 and 2.016


-- 
Jul 09 2008