mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-05 07:45:59 +02:00
Fixed scope for switch with tuple member captures
This commit is contained in:
parent
041a17cf89
commit
7c292a8814
1 changed files with 4 additions and 1 deletions
|
@ -4343,6 +4343,7 @@ void BfModule::Visit(BfSwitchStatement* switchStmt)
|
||||||
mBfIRBuilder->SetInsertPoint(noSwitchBlock);
|
mBfIRBuilder->SetInsertPoint(noSwitchBlock);
|
||||||
|
|
||||||
bool isPayloadEnum = switchValue.mType->IsPayloadEnum();
|
bool isPayloadEnum = switchValue.mType->IsPayloadEnum();
|
||||||
|
bool isTuple = switchValue.mType->IsTuple();
|
||||||
bool isIntegralSwitch = switchValue.mType->IsIntegral() || (intCoercibleType != NULL) || ((switchValue.mType->IsEnum()) && (!isPayloadEnum));
|
bool isIntegralSwitch = switchValue.mType->IsIntegral() || (intCoercibleType != NULL) || ((switchValue.mType->IsEnum()) && (!isPayloadEnum));
|
||||||
|
|
||||||
auto _ShowCaseError = [&] (int64 id, BfAstNode* errNode)
|
auto _ShowCaseError = [&] (int64 id, BfAstNode* errNode)
|
||||||
|
@ -4433,6 +4434,8 @@ void BfModule::Visit(BfSwitchStatement* switchStmt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wantsOpenedScope = isPayloadEnum || isTuple;
|
||||||
|
|
||||||
BfIRBlock lastNotEqBlock;
|
BfIRBlock lastNotEqBlock;
|
||||||
for (BfExpression* caseExpr : switchCase->mCaseExpressions)
|
for (BfExpression* caseExpr : switchCase->mCaseExpressions)
|
||||||
{
|
{
|
||||||
|
@ -4441,7 +4444,7 @@ void BfModule::Visit(BfSwitchStatement* switchStmt)
|
||||||
if (auto checkWhenExpr = BfNodeDynCast<BfWhenExpression>(caseExpr))
|
if (auto checkWhenExpr = BfNodeDynCast<BfWhenExpression>(caseExpr))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((!openedScope) && (isPayloadEnum))
|
if ((!openedScope) && (wantsOpenedScope))
|
||||||
{
|
{
|
||||||
openedScope = true;
|
openedScope = true;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue