www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8632] New: DMD accepts illegal template metaprogram

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

           Summary: DMD accepts illegal template metaprogram
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: timon.gehr gmx.ch



DMD 2.060:
template BrokenY(alias F){
    template BrokenY(A...){
        template Z(alias X){
            alias F!(X,A) Z;
        }
        alias Z!Z BrokenY;
    }
}
template AlmostFact(alias BrokenFact, int n){
    static if(n) enum AlmostFact = n*BrokenFact!(n-1);
    else enum AlmostFact=1;
}
alias BrokenY!AlmostFact BrokenFact;
pragma(msg, BrokenFact!3); // "36"

DMD accepts this code, but it is invalid. It seems to be some kind of lookup
problem. Consistently renaming one of the two BrokenFact aliases makes the
problem disappear.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 08 2012