1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 03:52:19 +02:00

Fixed some issues with new/delete generic constraints

This commit is contained in:
Brian Fiete 2020-02-20 11:57:25 -08:00
parent a781f29c31
commit c2c2c24ac8
9 changed files with 99 additions and 26 deletions

View file

@ -6536,22 +6536,22 @@ BfTypedValue BfModule::TryLookupGenericConstVaue(BfIdentifierNode* identifierNod
return BfTypedValue(mBfIRBuilder->GetFakeVal(), genericTypeConstraint);
}
if ((genericParamDef->mGenericParamFlags & BfGenericParamFlag_Const) == 0)
Fail("Only const generic parameters can be used a value", identifierNode);
if ((genericTypeConstraint != NULL) && (expectingType != NULL))
{
if (!CanCast(BfTypedValue(mBfIRBuilder->GetFakeVal(), genericTypeConstraint), expectingType))
if ((genericParamDef->mGenericParamFlags & BfGenericParamFlag_Const) != 0)
{
if ((genericTypeConstraint != NULL) && (expectingType != NULL))
{
Fail(StrFormat("Generic constraint '%s' is not convertible to 'int'", TypeToString(genericTypeConstraint).c_str()), identifierNode);
if (!CanCast(BfTypedValue(mBfIRBuilder->GetFakeVal(), genericTypeConstraint), expectingType))
{
Fail(StrFormat("Generic constraint '%s' is not convertible to 'int'", TypeToString(genericTypeConstraint).c_str()), identifierNode);
}
}
BfTypedValue result;
result.mType = genericParamResult;
result.mKind = BfTypedValueKind_GenericConstValue;
return result;
}
BfTypedValue result;
result.mType = genericParamResult;
result.mKind = BfTypedValueKind_GenericConstValue;
return result;
}
}
}