[Issue 8632] DMD accepts illegal template metaprogram

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Nov 24 10:31:13 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=8632


timon.gehr at gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME


--- Comment #2 from timon.gehr at gmx.ch 2013-11-24 10:31:11 PST ---
(In reply to comment #1)
> Errors, errors everywhere.
> 
> DMD v2.065 DEBUG
> testx.d(6): Error: alias testx.BrokenY!(AlmostFact).BrokenFact!3.BrokenY
> recursive alias declaration

I am not sure why this error should occur. Maybe this is spurious.

> testx.d(10): Error: template instance BrokenFact!(n - 1) BrokenFact is not a
> 

This is indeed the exact problem.

> No idea what that code is supposed to do,

It is supposed to make the compiler emit errors. :o)

It is a more or less random variation of the following valid code, also from my
test suite (this implements a template-level fixpoint combinator without using
explicit recursive template instantiations):

template Y(alias F){
    template Z(alias X){
        template Z(A...){
            alias F!(X!X,A) Z;
    }
    }
    alias Z!Z Y;
}

template AlmostFact(alias Fact, int n){
    static if(n) enum AlmostFact = n*Fact!(n-1);
    else enum AlmostFact=1;
}

alias Y!AlmostFact Fact;
pragma(msg, "Fact: ",Fact!5);
static assert(Fact!5==120);


> but maybe it's fixed?

Definitely. Thanks for checking!

-- 
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