mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Fixed enum issues utilizing Underlying in initializer
This commit is contained in:
parent
f7b3f88868
commit
fa251b3439
3 changed files with 28 additions and 2 deletions
|
@ -22357,7 +22357,7 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup,
|
|||
BfIRValue fromBool;
|
||||
mBfIRBuilder->RestoreDebugLocation();
|
||||
|
||||
if (!mCompiler->mIsResolveOnly)
|
||||
if ((!mCompiler->mIsResolveOnly) || (mIsComptimeModule))
|
||||
{
|
||||
if (!mCurTypeInstance->IsValuelessType())
|
||||
ret = mBfIRBuilder->CreateRet(GetThis().mValue);
|
||||
|
|
|
@ -3590,7 +3590,13 @@ void BfModule::DoPopulateType_InitSearches(BfTypeInstance* typeInstance)
|
|||
}
|
||||
|
||||
void BfModule::DoPopulateType_FinishEnum(BfTypeInstance* typeInstance, bool underlyingTypeDeferred, HashContext* dataMemberHashCtx, BfType* unionInnerType)
|
||||
{
|
||||
{
|
||||
if (typeInstance->mDefineState >= BfTypeDefineState_DefinedAndMethodsSlotting)
|
||||
{
|
||||
// Already locked
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeInstance->IsEnum())
|
||||
{
|
||||
int64 min = 0;
|
||||
|
|
|
@ -88,6 +88,20 @@ namespace Tests
|
|||
// Started from 129 elements, no less
|
||||
}
|
||||
|
||||
[AllowDuplicates]
|
||||
public enum EnumJ : uint32
|
||||
{
|
||||
SDL_BUTTON_LEFT = 1,
|
||||
SDL_BUTTON_LMASK = (1u << ((SDL_BUTTON_LEFT.Underlying) - 1)),
|
||||
}
|
||||
|
||||
[AllowDuplicates]
|
||||
public enum EnumK
|
||||
{
|
||||
SDL_BUTTON_LEFT = 1,
|
||||
SDL_BUTTON_LMASK = (1u << ((SDL_BUTTON_LEFT.Underlying) - 1)),
|
||||
}
|
||||
|
||||
[Test]
|
||||
static void TestBasic()
|
||||
{
|
||||
|
@ -229,6 +243,12 @@ namespace Tests
|
|||
if (ei case .DY(var eh))
|
||||
foundH = eh == .B;
|
||||
Test.Assert(foundH);
|
||||
|
||||
Test.Assert((int)EnumJ.SDL_BUTTON_LMASK == 1);
|
||||
Test.Assert(typeof(EnumJ).Size == 4);
|
||||
|
||||
Test.Assert((int)EnumK.SDL_BUTTON_LMASK == 1);
|
||||
Test.Assert(typeof(EnumK).Size == 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue