mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Properly fail enum case declarations outside enums
This commit is contained in:
parent
d1d3af1cc0
commit
234aaa772c
1 changed files with 23 additions and 15 deletions
|
@ -3592,6 +3592,8 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|||
BfType* resolvedFieldType = NULL;
|
||||
|
||||
if (field->IsEnumCaseEntry())
|
||||
{
|
||||
if (typeInstance->IsEnum())
|
||||
{
|
||||
fieldInstance->mDataIdx = -(enumCaseEntryIdx++) - 1;
|
||||
resolvedFieldType = typeInstance;
|
||||
|
@ -3612,6 +3614,12 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|||
fieldInstance->mIsEnumPayloadCase = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Fail("Enum cases can only be declared within enum types", field->GetRefNode(), true);
|
||||
resolvedFieldType = typeInstance;
|
||||
}
|
||||
}
|
||||
else if ((field->mTypeRef != NULL) && ((field->mTypeRef->IsExact<BfVarTypeReference>()) || (field->mTypeRef->IsExact<BfLetTypeReference>()) || (field->mTypeRef->IsExact<BfExprModTypeRef>())))
|
||||
{
|
||||
resolvedFieldType = GetPrimitiveType(BfTypeCode_Var);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue