Fix bug in type marking when replacing variables with abstract types