Add assertion and fix AST identity that had broken by template instantiation

Mentioned by @klickverbot in dmd-internal forum.

http://forum.dlang.org/thread/CAP9J_HXbtgevkav0DvowRHsTfT=S1zWh=wnzyqkGVoGqs34Nzw@mail.gmail.com