Fix bug 4269 case 13:invalid template accepted if evaluated while errors are gagged

Need to ungag template declarations if they are forward referenced.
Merge pull request #1491 from donc/d1merge4269

D1: 4269 case 13:invalid template accepted if evaluated while errors are gagged