Fix small assert ordering (#143)

This commit is contained in:
Rerumu 2021-11-05 17:38:08 -04:00 committed by GitHub
parent ad9b47b72f
commit 6342913533
Signed by: DevComp
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2465,9 +2465,10 @@ struct Compiler
} }
else if (node->is<AstStatBreak>()) else if (node->is<AstStatBreak>())
{ {
LUAU_ASSERT(!loops.empty());
// before exiting out of the loop, we need to close all local variables that were captured in closures since loop start // before exiting out of the loop, we need to close all local variables that were captured in closures since loop start
// normally they are closed by the enclosing blocks, including the loop block, but we're skipping that here // normally they are closed by the enclosing blocks, including the loop block, but we're skipping that here
LUAU_ASSERT(!loops.empty());
closeLocals(loops.back().localOffset); closeLocals(loops.back().localOffset);
size_t label = bytecode.emitLabel(); size_t label = bytecode.emitLabel();
@ -2478,12 +2479,13 @@ struct Compiler
} }
else if (AstStatContinue* stat = node->as<AstStatContinue>()) else if (AstStatContinue* stat = node->as<AstStatContinue>())
{ {
LUAU_ASSERT(!loops.empty());
if (loops.back().untilCondition) if (loops.back().untilCondition)
validateContinueUntil(stat, loops.back().untilCondition); validateContinueUntil(stat, loops.back().untilCondition);
// before continuing, we need to close all local variables that were captured in closures since loop start // before continuing, we need to close all local variables that were captured in closures since loop start
// normally they are closed by the enclosing blocks, including the loop block, but we're skipping that here // normally they are closed by the enclosing blocks, including the loop block, but we're skipping that here
LUAU_ASSERT(!loops.empty());
closeLocals(loops.back().localOffset); closeLocals(loops.back().localOffset);
size_t label = bytecode.emitLabel(); size_t label = bytecode.emitLabel();