1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-24 18:48:01 +02:00

Fixed out variable lifetimes, further unified out var for case+method

This commit is contained in:
Brian Fiete 2025-02-23 10:26:05 -08:00
parent 2bf2173e86
commit 35739e7293
4 changed files with 76 additions and 59 deletions

View file

@ -2438,16 +2438,9 @@ void BfModule::HandleCaseEnumMatch_Tuple(BfTypedValue tupleVal, const BfSizedArr
if (prevHadFallthrough)
Fail("Destructuring cannot be used when the previous case contains a fallthrough", expr);
CreateOutVariable(expr, varDecl, NULL, tupleElement.mType, tupleElement);
auto localVar = HandleVariableDeclaration(varDecl, tupleElement, false, true);
localVar->mReadFromId = 0; // Don't give usage errors for binds
auto curScope = mCurMethodState->mCurScope;
if (curScope->mScopeKind == BfScopeKind_StatementTarget)
{
// Move this variable into the parent scope
curScope->mLocalVarStart = localVar->mLocalVarIdx + 1;
}
continue;
}
@ -2473,10 +2466,7 @@ void BfModule::HandleCaseEnumMatch_Tuple(BfTypedValue tupleVal, const BfSizedArr
localVar->mReadFromId = 0; // Don't give usage errors for binds
auto curScope = mCurMethodState->mCurScope;
if (curScope->mScopeKind == BfScopeKind_StatementTarget)
{
// Move this variable into the parent scope
curScope->mLocalVarStart = localVar->mLocalVarIdx + 1;
}
MoveLocalToParentScope(localVar);
continue;
}
}