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

https://d.puremagic.com/issues/show_bug.cgi?id=11487

`TemplateMixin` should call `setScope` for its members.