mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 12:02:21 +02:00
Allow enums with <=1 element (void underlying) cast to int (0)
This commit is contained in:
parent
9ca3fbd0dd
commit
b12b49aec3
1 changed files with 7 additions and 0 deletions
|
@ -14611,6 +14611,13 @@ BfIRValue BfModule::CastToValue(BfAstNode* srcNode, BfTypedValue typedVal, BfTyp
|
||||||
auto fromTypedPrimitiveType = typedVal.mType->ToTypeInstance();
|
auto fromTypedPrimitiveType = typedVal.mType->ToTypeInstance();
|
||||||
auto primTypedVal = BfTypedValue(typedVal.mValue, fromTypedPrimitiveType->mFieldInstances.back().mResolvedType, typedVal.IsAddr());
|
auto primTypedVal = BfTypedValue(typedVal.mValue, fromTypedPrimitiveType->mFieldInstances.back().mResolvedType, typedVal.IsAddr());
|
||||||
primTypedVal = LoadValue(primTypedVal);
|
primTypedVal = LoadValue(primTypedVal);
|
||||||
|
|
||||||
|
if ((typedVal.mType->IsEnum()) && (primTypedVal.IsValuelessType()))
|
||||||
|
{
|
||||||
|
// For enums with <= 1 member, fake an int8(0) instead of a void
|
||||||
|
primTypedVal = GetDefaultTypedValue(GetPrimitiveType(BfTypeCode_Int8));
|
||||||
|
}
|
||||||
|
|
||||||
return CastToValue(srcNode, primTypedVal, toType, castFlags);
|
return CastToValue(srcNode, primTypedVal, toType, castFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue