mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-14 14:24:10 +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);
|
||||
auto constraintTypeInst = genericParamInst->mTypeConstraint->ToTypeInstance();
|
||||
if ((constraintTypeInst != NULL) && (constraintTypeInst->mTypeDef == mCompiler->mEnumTypeDef))
|
||||
if ((constraintTypeInst != NULL) && (constraintTypeInst->mTypeDef == mCompiler->mEnumTypeDef) && (explicitCast))
|
||||
{
|
||||
// Enum->int
|
||||
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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue