[Issue 2379] New: CTFE fails to evaluate if unless it is very straightforward
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Sep 29 16:35:20 PDT 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2379
Summary: CTFE fails to evaluate if unless it is very
straightforward
Product: D
Version: 2.019
Platform: PC
OS/Version: Windows
Status: NEW
Severity: critical
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: 2korden at gmail.com
First attempt:
-----------
template Test0(invariant(char)[] text)
{
auto Test0 = text;
}
writefln(Test0!("hello")); // success
pragma(msg, Test0!("hello")); // failure:
// pragma msg string expected for message, not 'Test0'
Let's replace invariant(char)[] with alias :(
-----------
template Test0(alias text)
{
auto Test0 = text;
}
pragma(msg, Test0!("hello")); // success
Let's make it slightly more complex:
-----------
template Test0(alias text)
{
auto Test0 = text[0..1];
}
pragma(msg, Test0!("hello")); // failure:
// pragma msg string expected for message, not 'Test0'
Other example:
-----------
template Test0(invariant(char)[] text)
{
auto Test0 = text;
}
template Test1(invariant(char)[] text)
{
auto Test1 = Test0!(text);
}
writefln(Test0!("hello")); // success
writefln(Test1!("hello")); // failure:
// Error: non-constant expression Test0
--
More information about the Digitalmars-d-bugs
mailing list