Improve error recovery in the typechecker