I'm trying to write a particular template, and once I got to a certain point, I got DMD to crash. I'm attaching the file with the offending code. The compiler output is:
> Assertion failed: (0), function totym, file glue.c, line 1235.
> Abort trap: 6
I tested this with DMD 2.061 on WIndows and Mac OS X.
Comment #1 by casantander1 — 2013-02-19T16:32:15Z
Created attachment 1193
test case
Comment #2 by maxim — 2013-02-20T03:45:03Z
That's because Type::totym() during object file generation got Terror value, which is not switched. Error message can be improved by checking for such value and printing usual error, but the real problem is that Terror escaped frontend.
Comment #3 by maxim — 2013-02-20T03:46:04Z
(In reply to comment #0)
> > Assertion failed: (0), function totym, file glue.c, line 1235.
> > Abort trap: 6
>
> I tested this with DMD 2.061 on WIndows and Mac OS X.
Can confirm on linux githead.
Comment #4 by maxim — 2013-02-20T05:27:24Z
Reduced:
module failure;
template Tuple(E...) { alias E Tuple; }
alias Tuple!(int) Args;
void main() {
(new A).test ();
}
void test1 (int delegate (int) f) { f (-2); }
class A
{
int f (int a) {
return a;
}
void test () {
test1 (&AddFront!(this, f));
}
}
template AddFront (alias ctx, alias fun) {
auto AddFront(Args args) {
auto dg (Args dgArgs) {
return fun (dgArgs);
}
dg.ptr = ctx;
return dg(args);
}
}
Comment #5 by dmitry.olsh — 2013-04-14T05:24:43Z
Nice job at reduction.
I'm hitting the same issue while trying to integrate new std.uni into Phobos
but the circumstances are different. I'm certainly not trying to do anything
funky with delegate pointers.
The message is the same for me (both with your minimal test and when compiling anything in my fork of phobos):
dmd: glue.c:1215: virtual unsigned int Type::totym(): Assertion `0' failed.
Aborted
Now if only dustmite didn't crush on it... we'd have another case.
Now the reduced code reports following errors.
test.d(26): Error: function test.A.test.AddFront!(this, f).AddFront.dg (int _param_0) is not callable using argument types ()
test.d(17): Error: template instance test.A.test.AddFront!(this, f) error instantiating
auto dg (Args dgArgs) {
return fun (dgArgs);
}
dg.ptr = ctx; // <-- line 26
dg is not a delegate, it is a nested function. So it does not have `ptr` property.