mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-15 23:04:09 +02:00
Require explicit cast for enum-constrained generic-to-int conversion
This commit is contained in:
parent
d460c1fb2f
commit
2d76efdaaa
1 changed files with 2 additions and 2 deletions
|
@ -11079,7 +11079,7 @@ BfIRValue BfModule::CastToValue(BfAstNode* srcNode, BfTypedValue typedVal, BfTyp
|
||||||
{
|
{
|
||||||
SetAndRestoreValue<bool> prevIgnoreWrites(mBfIRBuilder->mIgnoreWrites, true);
|
SetAndRestoreValue<bool> prevIgnoreWrites(mBfIRBuilder->mIgnoreWrites, true);
|
||||||
auto constraintTypeInst = genericParamInst->mTypeConstraint->ToTypeInstance();
|
auto constraintTypeInst = genericParamInst->mTypeConstraint->ToTypeInstance();
|
||||||
if ((constraintTypeInst != NULL) && (constraintTypeInst->mTypeDef == mCompiler->mEnumTypeDef))
|
if ((constraintTypeInst != NULL) && (constraintTypeInst->mTypeDef == mCompiler->mEnumTypeDef) && (explicitCast))
|
||||||
{
|
{
|
||||||
// Enum->int
|
// Enum->int
|
||||||
if ((explicitCast) && (toType->IsInteger()))
|
if ((explicitCast) && (toType->IsInteger()))
|
||||||
|
@ -11118,7 +11118,7 @@ BfIRValue BfModule::CastToValue(BfAstNode* srcNode, BfTypedValue typedVal, BfTyp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toType->IsInteger())
|
if ((toType->IsInteger()) && (explicitCast))
|
||||||
{
|
{
|
||||||
if ((genericParamInst->mGenericParamFlags & BfGenericParamFlag_Enum) != 0)
|
if ((genericParamInst->mGenericParamFlags & BfGenericParamFlag_Enum) != 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue