[Issue 3867] Complex bug with a forward referenced enum member via an alias, templates, tuples, and CTFE
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Mar 2 10:46:10 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3867
Matti Niemenmaa <matti.niemenmaa+dbugzilla at iki.fi> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid, wrong-code
Summary|forward delcaration |Complex bug with a forward
|generates very stange bug |referenced enum member via
| |an alias, templates,
| |tuples, and CTFE
--- Comment #3 from Matti Niemenmaa <matti.niemenmaa+dbugzilla at iki.fi> 2010-03-02 10:46:07 PST ---
Here I come to save the day! To be fair, this is a /bit/ different in that the
original evaluated to the wrong thing twice, but I think that's related to the
compilation errors there, which are either a separate bug or also caused by
this (possible, given that removing the misbehaving code there also
mysteriously fixes the errors).
Anyway, here's something a bit shorter (though still involving just about every
nontrivial language feature) showing this problem:
enum ArrayFlags { None }
class NArray(T) {
uint flags = Flags.None;
alias ArrayFlags Flags;
}
char[] axisFilterLoop(S...)() {
static if (is(S[0]==NArray!(double))) {}
return "yyyy";
}
//pragma(msg, "Outside: " ~ axisFilterLoop!(NArray!(int))());
void axisFilter1(S...)() {
pragma(msg, "Inside: " ~ axisFilterLoop!(S)());
}
void main() { axisFilter1!(NArray!(int))(); }
As shown above, the code prints:
"Inside: " ~ axisFilterLoop()
Inside: yyyy
Note that axisFilter1 is instantiated and run only once, yet we get two lines
of output. If you uncomment the other pragma(msg) you get:
Outside: yyyy
Inside: yyyy
As expected.
And yes, you need things like the false-giving (testing for the correct
NArray!(int) instead of NArray!(double) hides the bug) static if on S[0] on
line 9 and the access to the enum member through the alias on lines 4-5.
--
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