If "struct Relative" is defined at the outer of doTest(), everything is OK. Here are the test codes: ===================================== import std.stdio; void doTest() { struct Relative { int xBase; int xDir; // This method causes a compiler internal error void MoveTo() { } } Relative rel = {1, 2}; } int main(string[] args) { return 0; } =====================================
This fails for both kinds of struct initializers, Struct(...) and {...}. Workaround is to use a static struct and pass the context as needed. Thanks for reducing this!
Even simple workaround - use structname(args) instead of { args }. https://github.com/D-Programming-Language/dmd/pull/253
https://github.com/D-Programming-Language/dmd/commit/523a8c91a0761543a8757b99e3e3d9fe2fe993e2