There are two issues here, the first is in phobos that somewhere in the pipeline generates a ridiculous amount of template instances.
Second is the recursive nature of 'TemplateInstance::needsCodegen()' that overflows the stack when there are too many instances of a particular template, this is the same bug as issue 18026 and the only way to fix it is to refactor 'needsCodegen' function. You can reproduce it with this simple piece of code:
---------------
struct S() {}
static foreach (i; 0..180000)
{
mixin("S!() s", i, ";");
}
---------------
The number of iterations can vary, for example using a non-optimized DMD build I only need '90000' to crash. (my stack size is 8MB)
Comment #2 by n8sh.secondary — 2021-03-12T17:08:11Z