1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-07-04 23:36:00 +02:00

Fixed scope for switch with tuple member captures

This commit is contained in:
Brian Fiete 2021-11-27 11:11:41 -08:00
parent 041a17cf89
commit 7c292a8814

View file

@ -4343,6 +4343,7 @@ void BfModule::Visit(BfSwitchStatement* switchStmt)
mBfIRBuilder->SetInsertPoint(noSwitchBlock);
bool isPayloadEnum = switchValue.mType->IsPayloadEnum();
bool isTuple = switchValue.mType->IsTuple();
bool isIntegralSwitch = switchValue.mType->IsIntegral() || (intCoercibleType != NULL) || ((switchValue.mType->IsEnum()) && (!isPayloadEnum));
auto _ShowCaseError = [&] (int64 id, BfAstNode* errNode)
@ -4433,6 +4434,8 @@ void BfModule::Visit(BfSwitchStatement* switchStmt)
}
}
bool wantsOpenedScope = isPayloadEnum || isTuple;
BfIRBlock lastNotEqBlock;
for (BfExpression* caseExpr : switchCase->mCaseExpressions)
{
@ -4441,7 +4444,7 @@ void BfModule::Visit(BfSwitchStatement* switchStmt)
if (auto checkWhenExpr = BfNodeDynCast<BfWhenExpression>(caseExpr))
continue;
if ((!openedScope) && (isPayloadEnum))
if ((!openedScope) && (wantsOpenedScope))
{
openedScope = true;