[Issue 6094] && doesn't shortcut properly with CTFE
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jun 2 21:31:54 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6094
Steven Schveighoffer <schveiguy at yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |schveiguy at yahoo.com
--- Comment #1 from Steven Schveighoffer <schveiguy at yahoo.com> 2011-06-02 21:27:28 PDT ---
Hm... I'm not so sure this is a valid requirement.
&& shortcuts *running* the code if the first test fails, but it doesn't
shortcut *compiling* the code. I think you need to use a static if in this
case.
For example, I'd expect this also to fail to compile:
void main()
{
int x;
if(is(typeof(x) == string) && x == "5") {}
}
But I'd expect this to work:
void main()
{
int x;
static if(is(typeof(x) == string))
if(x == "5") {}
}
I would expect something like this to work in your example instead:
static if(is(typeof(pred) : string))
enum defaultPred = (pred == "a == b");
else
enum defaultPred = false;
--
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