Bug 752 – Assertion failure: 'e->type->ty != Ttuple' on line 4518 in file 'mtype.c'

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-12-26T14:04:00Z
Last change time
2014-02-15T13:19:29Z
Keywords
ice-on-valid-code
Assigned to
bugzilla
Creator
sean

Comments

Comment #0 by sean — 2006-12-26T14:04:08Z
The code: struct Tuple( TList... ) { const size_t length = TList.length; private: typeof(TList[0]) head; static if( length > 1 ) mixin .Tuple!((TList[1 .. $])) tail; } void main() { Tuple!(int, long) T; T val; printf( "%u\n", val.length ); } Gives the following errors: C:\code\src\d\test>dmd test test.d(9): Error: Integer constant expression expected instead of cast(int)(__dollar) test.d(9): Error: string slice [1 .. 0] is out of bounds Assertion failure: 'e->type->ty != Ttuple' on line 4518 in file 'mtype.c' abnormal program termination The __dollar issue can be eliminated by replacing '$' with TList.length, but the assertion failure remains. Marking ICE on valid despite the dollar issue.
Comment #1 by thomas-dloop — 2006-12-27T06:10:39Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] schrieb am 2006-12-26: > http://d.puremagic.com/issues/show_bug.cgi?id=752 > The code: > > struct Tuple( TList... ) > { > const size_t length = TList.length; > > private: > typeof(TList[0]) head; > static if( length > 1 ) > mixin .Tuple!((TList[1 .. $])) tail; > } > > void main() > { > Tuple!(int, long) T; > T val; > printf( "%u\n", val.length ); > } > > Gives the following errors: > > C:\code\src\d\test>dmd test > test.d(9): Error: Integer constant expression expected instead of > cast(int)(__dollar) > test.d(9): Error: string slice [1 .. 0] is out of bounds > Assertion failure: 'e->type->ty != Ttuple' on line 4518 in file 'mtype.c' > > abnormal program termination > > The __dollar issue can be eliminated by replacing '$' with TList.length, but > the assertion failure remains. Marking ICE on valid despite the dollar issue. Added to DStress as http://dstress.kuehne.cn/nocompile/t/tuple_09_A.d http://dstress.kuehne.cn/nocompile/t/tuple_09_B.d http://dstress.kuehne.cn/nocompile/t/tuple_09_C.d http://dstress.kuehne.cn/nocompile/t/tuple_09_D.d http://dstress.kuehne.cn/nocompile/t/tuple_09_E.d http://dstress.kuehne.cn/nocompile/t/tuple_09_F.d http://dstress.kuehne.cn/compile/t/tuple_09_G.d http://dstress.kuehne.cn/compile/t/tuple_09_H.d http://dstress.kuehne.cn/compile/t/tuple_09_I.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFFklE+LK5blCcjpWoRAnUeAKClxusf62DZEhW/Ey0m3sHxrwAIcQCdHbGe zlSTxLz0aJSqKBftW68VrAs= =6sed -----END PGP SIGNATURE-----
Comment #2 by bugzilla — 2006-12-29T21:43:49Z
The statement: mixin .Tuple!((TList[1 .. $])) is actually invalid, as it attempts to make a tuple of tuples. Instead, mixin .Tuple!(TList[1 .. $]) is correct. This is also wrong: Tuple!(int, long) T; T val; as T is not declared as being a type. The issue of length not being resolved is still a bug, though.
Comment #3 by sean — 2006-12-29T21:50:24Z
[email protected] wrote: > > ------- Comment #2 from [email protected] 2006-12-29 21:43 ------- > The statement: > > mixin .Tuple!((TList[1 .. $])) > > is actually invalid, as it attempts to make a tuple of tuples. Instead, > > mixin .Tuple!(TList[1 .. $]) > > is correct. This seems a slim distinction. Adding a set of parenthesis makes the code invalid? > This is also wrong: > > Tuple!(int, long) T; > T val; > > as T is not declared as being a type. Yup, I'm aware of this. The code actually has a few bugs in it. But it still shouldn't cause an assertion failure in the compiler.
Comment #4 by bugzilla — 2007-01-03T22:13:07Z
Fixed DMD 1.00
Comment #5 by davidl — 2008-08-12T09:17:23Z
1.033 dead loop with error message: kuehne\nocompile\t\tuple_09_D.d(15): Error: string slice [1 .. 1] is out of bounds module dstress.nocompile.t.tuple_09_D; struct Tuple( TList... ){ mixin .Tuple!((TList[1 .. $])) tail; } mixin Tuple!(int);
Comment #6 by clugdbug — 2009-05-14T04:57:46Z
Fixed DMD2.030 and 1.045.