[cleanup] Tweak existing code around `new TemplateInstance`
fix Issue 12037 - Link-failure with std.numeric.CustomFloat
Merge pull request #3177 from 9rnsr/fix12037

[REG2.065a] Issue 12037 - Link-failure with std.numeric.CustomFloat
fix Issue 12040 - Compiler segfault with circular reference in variable type
Merge pull request #3178 from 9rnsr/fix12040

Issue 12040 - Compiler segfault with circular reference in variable type