Bug 1779 – Compiler crash when deducing more than 2 type args
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2008-01-10T13:49:00Z
Last change time
2015-06-09T01:14:25Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
paul_m_doc
Comments
Comment #0 by paul_m_doc — 2008-01-10T13:49:10Z
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