The following code when trying to compile triggers an assert in dmd.
module main;
void main(string[] args)
{
immutable int a;
immutable int b;
test!a ta;
test!b tb;
}
struct test(alias a){}
>dmd main.d
Assertion failure: 'type->ty != Tstruct || ((TypeStruct *)type)->sym == this' on line 929 in file 'struct.c'
Comment #1 by joeyemmons — 2015-06-26T21:55:25Z
Should have said
DMD32 D Compiler v2.067.1
Comment #2 by dlang-bugzilla — 2015-06-28T13:59:53Z
(In reply to joeyemmons from comment #0)
> Assertion failure: 'type->ty != Tstruct || ((TypeStruct *)type)->sym ==
> this' on line 929 in file 'struct.c'
(In reply to Vladimir Panteleev from comment #2)
> https://github.com/D-Programming-Language/dmd/pull/1760
> https://github.com/D-Programming-Language/dmd/pull/2645
> https://github.com/D-Programming-Language/dmd/pull/3383
The root issue is in the template mangling process. Currently typeof(ta) and typeof(tb) are angled to the same name S4main14__T4testVyii0Z4test, but I think it's wrong - the given argument `a` and `b` should be mangled differently on alias parameter.
And the issue has existed from the previous of 2.062, the generated executable had silently corrupted. The added assertion is detecting the compiler internal structure issue correctly today.
Downgrade to 'critical' issue.
Comment #4 by dfj1esp02 — 2015-10-21T12:17:40Z
---
void f()
{
int a, b;
test!a ta;
test!b tb;
}
struct test(alias a){}
---
For some reason this compiles. Do instances have different mangled name here?