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.
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);