www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 570] New: Bogus recursive mixin error

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=570

           Summary: Bogus recursive mixin error
           Product: D
           Version: 0.174
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: rejects-valid
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: daekharel gmail.com


import std.stdio;

template TupleDecls(T, R ...) {
    T value;
    static if (R.length)
        mixin TupleDecls!(R) Inner;
}

struct TupleStruct(T ...) { mixin TupleDecls!(T); }

void main() {
    alias TupleStruct!(char[], char[]) twoStrings;
}

---------
The above code generates the following errors when compiling:

err.d(6): mixin
err.TupleStruct!(char[],char[]).TupleStruct.TupleDecls!(char[],char[]).TupleDecls!(char[])
recursive mixin instantiation
err.d(12): template instance err.TupleStruct!(char[],char[]) error
instantiating

The compiler seems to think that TupleDecls!(char[]) is the same as
TupleDecls!(char[], char[]) somehow, and rejects instantiating the former
inside the latter as being recursive, even though it's not.


-- 
Nov 18 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=570






Correction: it is recursive, but not infinitely recursive, as instantiating
TupleDecls!(char[], char[]) inside of TupleDecls!(char[], char[]) would be.
Also, the compiler accepts this code just fine when the types passed to the
template aren't the same, as in TupleDecls!(char[], int).


-- 
Nov 18 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=570


bugzilla digitalmars.com changed:

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





Fixed dmd 1.032 and 2.016


-- 
Jul 09 2008