1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 03:28:20 +02:00

Merge pull request #2171 from aharabada/DeferCrash

Fixed crash when defer scope target doesn't exist
This commit is contained in:
Brian Fiete 2025-03-04 11:25:12 -08:00 committed by GitHub
commit 4deb97a484
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7283,7 +7283,16 @@ void BfModule::Visit(BfDeferStatement* deferStmt)
scope = &mCurMethodState->mHeadScope;
}
else if (deferStmt->mScopeName != NULL)
{
scope = FindScope(deferStmt->mScopeName, true);
if (scope == NULL)
{
AssertErrorState();
// The scope doesn't exist, continue with the current scope so we still get an evaluation of the deferred code
scope = mCurMethodState->mCurScope;
}
}
else
scope = mCurMethodState->mCurScope;