Type mismatch when same attribute name is used with different types