Fix substitution typecheck