Fix bad pop on bare except-finally

This commit is contained in:
K. Lange 2021-03-19 11:38:26 +09:00
parent dec38c410c
commit 2d3e7ca3d3
3 changed files with 25 additions and 0 deletions

View File

@ -1820,6 +1820,7 @@ _anotherExcept:
emitByte(OP_BEGIN_FINALLY);
exitJumps = 0;
if (nextJump != -1) {
emitByte(OP_NONE);
patchJump(nextJump);
emitByte(OP_POP);
}

18
test/testBareFinally.krk Normal file
View File

@ -0,0 +1,18 @@
try:
raise ValueError()
except ValueError as e:
print(repr(e))
finally:
print("Done?")
try:
print("try")
finally:
print('finally')
try:
print('try')
except Exception as e:
print('except')
finally:
print('finally')

View File

@ -0,0 +1,6 @@
ValueError(None)
Done?
try
finally
try
finally