[Issue 2089] New: Issues with CTFE and tuple indexes

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri May 9 09:45:33 PDT 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2089

           Summary: Issues with CTFE and tuple indexes
           Product: D
           Version: 1.029
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: samukha at voliacable.com


----
template Tuple(A...)
{
    alias A Tuple;
}

alias Tuple!("one", "two") tuple;

size_t foo()
{
    return 1;
}

static assert(tuple[foo()] == "two");

void main() {}
----
Output:
test.d(24): Error: Integer constant expression expected instead of foo()

Bogus output when the tuple is indexed in msg pragma (introducing an
intermediate const does not help):

----
template Tuple(A...)
{
    alias A Tuple;
}

alias Tuple!("one", "two") tuple;

size_t foo()
{
    return 1;
}

const i = foo();

pragma(msg, tuple[i]); // fails
// static assert(tuple[i] == "two"); // while this passes

void main() {}
----
Output:
test.d(24): Error: Integer constant expression expected instead of foo()
one

IIRC, a similar bug was posted long time ago. If anybody can find it, please
mark it a duplicate.


-- 



More information about the Digitalmars-d-bugs mailing list