[Issue 12166] Template Argument Pattern Matching Fails for Struct With Multiple Nested Template Arguments
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Feb 20 04:31:51 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12166
--- Comment #4 from monkeyworks12 at hotmail.com 2014-02-20 04:31:48 PST ---
(In reply to comment #3)
> (In reply to comment #2)
> > Sorry, add:
> [snip]
>
> So, what version do you use? The full test case:
>
> struct Zero {}
> struct Succ(a) {}
>
> alias One = Succ!Zero;
> alias Two = Succ!One;
> alias Three = Succ!Two;
> alias Four = Succ!Three;
>
> struct Nil {}
> struct Cons(a, b) {}
>
> alias list1 = Cons!(Three, Cons!(Two, Cons!(Four, Cons!(One, Nil))));
>
> alias numlHead(L: Cons!(a, b), a, b) = a;
>
> alias numlTail(L: Cons!(a, b), a, b) = b;
>
> void main()
> {
> pragma(msg, numlHead!list1);
> }
>
> compiles with 2.064 (2.063 and earlier does not support new alias syntax). I
> cannot see the issue.
It seems it was an error on my part. In the full code, I had some testing code
in my main method. I accidentally named a variable list1 as well as having the
list1 alias, so my code broke with this:
void main()
{
//assert(is(Four == Succ!(Succ!(Succ!(Succ!Zero)))));
auto list1 = list1(); //Problem
//assert(is(typeof(three) == Three));
//assert(numValue!(Number!Zero) == 0);
assert(numValue!(Number!Four) == 4);
pragma(msg, numlHead!list1);
//assert(is(numlHead!list1 == Three));
//assert(is(typeof(numlTail!list1) == Cons!(Two, Cons!Four, Cons!(One,
Nil))));
}
However, it also seems this is bad behaviour. Should I open a separate report?
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list