Thread overview
[Issue 1102] New: switch case couldn't contain template member
Apr 06, 2007
d-bugmail
Apr 06, 2007
d-bugmail
Apr 06, 2007
d-bugmail
Apr 12, 2007
d-bugmail
April 06, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1102

           Summary: switch case couldn't contain template member
           Product: D
           Version: 1.010
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: davidl@126.com


In my opinion, the following should be compilable:
enum type{
        a,
        b,
}
class myclass
{
        template XX(uint a, uint c)
        {
                uint XX(){ return (a*256+c);}
        }
        void testcase()
        {
                switch (cast(uint)type.a)
                {
                case XX!(cast(uint)type.a,cast(uint)type.b)():  /*emit me error
message: case must be a string or an integral constant, not (this.XX)()*/
                        break;
                }

        }
}
void main()
{

}


-- 

April 06, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1102





------- Comment #1 from bugzilla@digitalmars.com  2007-04-06 02:12 -------
  uint XX(){ return (a*256+c);}

should be:

  static uint XX(){ return (a*256+c);}

as non-static member functions cannot be evaluated at compile time.


-- 

April 06, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1102


thomas-dloop@kuehne.cn changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         OS/Version|Windows                     |All




------- Comment #2 from thomas-dloop@kuehne.cn  2007-04-06 04:15 -------
Added to DStress as http://dstress.kuehne.cn/run/c/case_06_A.d http://dstress.kuehne.cn/run/c/case_06_B.d http://dstress.kuehne.cn/run/c/case_06_C.d http://dstress.kuehne.cn/run/c/case_06_D.d http://dstress.kuehne.cn/run/c/case_06_E.d http://dstress.kuehne.cn/run/c/case_06_F.d http://dstress.kuehne.cn/run/c/case_06_G.d http://dstress.kuehne.cn/run/c/case_06_H.d http://dstress.kuehne.cn/run/c/case_06_I.d http://dstress.kuehne.cn/run/c/case_06_J.d http://dstress.kuehne.cn/run/c/case_06_K.d


-- 

April 12, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1102


bugzilla@digitalmars.com changed:

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




------- Comment #3 from bugzilla@digitalmars.com  2007-04-11 22:03 -------
Fixed dmd 1.011


--