[Issue 1779] New: Compiler crash when deducing more than 2 type args

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 10 11:49:11 PST 2008


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

           Summary: Compiler crash when deducing more than 2 type args
           Product: D
           Version: 2.009
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: paul_m_doc at hotmail.com


The lack of compile-time reflection for class template arguments leads to the
following cumbersome code:

template Print(Ts ...) { pragma (msg, Ts.stringof); }

template Tuple(Ts ...) { alias Ts Tuple; }

template Decode( T )                                       { alias Tuple!()
Types; }
template Decode( T : TT!(U1),       alias TT, U1 )         { alias Tuple!(U1)
Types; }
template Decode( T : TT!(U1,U2),    alias TT, U1, U2 )     { alias
Tuple!(U1,U2) Types; }
template Decode( T : TT!(U1,U2,U3), alias TT, U1, U2, U3 ) { alias
Tuple!(U1,U2,U3) Types; }
// etc

struct S1(T1) {}
struct S2(T1, T2) {}
struct S3(T1, T2, T3) {}

alias Decode!( bool ).Types SQ0;
alias Decode!( S1!(bool) ).Types SQ1;
alias Decode!( S2!(bool,short) ).Types SQ2;
//alias Decode!( S3!(bool,short,int) ).Types SQ3;  // <-- crashes when
uncommented

mixin Print!(SQ0);
mixin Print!(SQ1);
mixin Print!(SQ2);
//mixin Print!(SQ3); // <-- and uncomment this


The compiler prints the deduced tuples as:

()
(bool)
(bool, short)

but crashes before printing the 3 arg case.

Came across this issue first with ver 2.007 but still present in 2.009


-- 



More information about the Digitalmars-d-bugs mailing list