fix Issue 11487 - dmd segfaults on writefln in nested template
Merge pull request #2848 from 9rnsr/fix11487

[REG2.063] Issue 11487 - dmd segfaults on writefln in nested template