Allow variables be assigned to other types if they are implicitly castable
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
9520b98f2e
commit
54778adf82
|
@ -101,8 +101,12 @@ namespace Porygon::Binder {
|
|||
} else {
|
||||
// Assigning
|
||||
auto var = this->GetVariable(exists, identifier);
|
||||
if (var->GetType()->operator!=(type)) {
|
||||
return VariableAssignment(VariableAssignmentResult::VariableDefinedWithDifferentType, nullptr);
|
||||
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));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue