Allow variables be assigned to other types if they are implicitly castable
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -101,9 +101,13 @@ namespace Porygon::Binder {
|
||||
} else {
|
||||
// Assigning
|
||||
auto var = this->GetVariable(exists, identifier);
|
||||
if (var->GetType()->operator!=(type)) {
|
||||
auto t= var->GetType();
|
||||
if (t->operator!=(type)) {
|
||||
auto castResult = type->CastableTo(t, false);
|
||||
if (castResult == CastResult::InvalidCast){
|
||||
return VariableAssignment(VariableAssignmentResult::VariableDefinedWithDifferentType, nullptr);
|
||||
}
|
||||
}
|
||||
return VariableAssignment(VariableAssignmentResult::Ok, new BoundVariableKey(identifier, exists, false, type));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user