http://d.puremagic.com/issues/show_bug.cgi?id=4941
Summary: TypeTuple slice boundaries are not CTFE'd Product: D Version: D1 & D2 Platform: All OS/Version: All Status: NEW Keywords: patch, rejects-valid Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: rsi...@gmail.com --- Comment #0 from Shin Fujishiro <rsi...@gmail.com> 2010-09-25 21:25:29 PDT --- Type tuples can't be sliced with boundaries that involve CTFE-able function call(s). The following valid code doesn't compile (both D1 & D2): -------------------- template T(_...) { alias _ T; } size_t mid(size_t n) { return n/2; } alias T!(int, int, int)[0 .. mid($)] A; // Error: Integer constant expression expected instead of mid(3u) -------------------- Patch against dmd r687, makes it sure that TypeSlice boundaries get CTFE'd. --- src/mtype.c +++ src/mtype.c @@ -7787,11 +7787,11 @@ Type *TypeSlice::semantic(Loc loc, Scope *sc) TypeTuple *tt = (TypeTuple *)tbn; lwr = semanticLength(sc, tbn, lwr); - lwr = lwr->optimize(WANTvalue); + lwr = lwr->optimize(WANTvalue | WANTinterpret); uinteger_t i1 = lwr->toUInteger(); upr = semanticLength(sc, tbn, upr); - upr = upr->optimize(WANTvalue); + upr = upr->optimize(WANTvalue | WANTinterpret); uinteger_t i2 = upr->toUInteger(); if (!(i1 <= i2 && i2 <= tt->arguments->dim)) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------