[Issue 4910] New: [CTFE] Cannot evaluate a function that has failed at once
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Sep 21 15:34:19 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4910
Summary: [CTFE] Cannot evaluate a function that has failed at
once
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: rsinfu at gmail.com
--- Comment #0 from Shin Fujishiro <rsinfu at gmail.com> 2010-09-21 15:33:40 PDT ---
If the interpretor failed to evaluate a function with an invalid argument at
once, then it fails to evaluate the same function with a valid argument.
The following code fails (it should succeed):
-------------------- test1.d
int echo(int a)
{
return a;
}
template ctfe(int v) { }
static int var;
static assert(!__traits(compiles, ctfe!(echo(var)) ));
enum c = echo(123); // (10)
--------------------
% dmd -o- -c test1.d
test1.d(10): Error: cannot evaluate echo(123) at compile time
test1.d(10): Error: cannot evaluate echo(123) at compile time
--------------------
But it succeeds if echo(123) is evaluated before the failure.
-------------------- test2.d
int echo(int a)
{
return a;
}
enum c = echo(123);
template ctfe(int v) { }
static int var;
static assert(!__traits(compiles, ctfe!(echo(var)) ));
--------------------
% dmd -o- -c test2.d
% _
--------------------
--
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