Can you put this code in `TemplateInstance::semantic` instead, and propagate errors there?