Improved type checking for assignment