www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1102] New: switch case couldn't contain template member

reply d-bugmail puremagic.com writes:
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()
{

}


-- 
Apr 05 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1102






  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.


-- 
Apr 06 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1102


thomas-dloop kuehne.cn changed:

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





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


-- 
Apr 06 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1102


bugzilla digitalmars.com changed:

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





Fixed dmd 1.011


-- 
Apr 11 2007