Fix several cases where the compiler would miss instantiation errors when type-checking directives