[Issue 7912] New: Cannot read compile variable at compile time
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Sat Apr 14 13:52:36 PDT 2012
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=7912
           Summary: Cannot read compile variable at compile time
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: jazeik at gmail.com
--- Comment #0 from Jan <jazeik at gmail.com> 2012-04-14 13:53:23 PDT ---
tst.d
----------------------------
import std.stdio;
import std.conv;
mixin template TTT()
{
    static const uint tst;
    static this()
    {
        tst = 0;
    }
}
class T
{
    mixin TTT;
}
void main()
{
    auto n = 0;
    switch(n)
    {
        case T.tst:
            writeln("T.tst: ", T.tst);
            break;
        default:
            writeln("default: ", n);
            break;
    }
}
----------------------------
Run with: 
> dmd -run tst.d
=============================
result:
> tst.d(23): Error: variable tst cannot be read at compile time
> tst.d(23): Error: variable tst cannot be read at compile time
> tst.d(23): Error: case must be a string or an integral constant, not cast(int)tst
=============================
Expected result:
> T.tst: 0
=============================
Additional Information:
Replace "switch(n)" with "switch(n | (T.tst))" to get expected result.
-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
    
    
More information about the Digitalmars-d-bugs
mailing list