Statically resolved locals are now popped off the stack (whoops)

This commit is contained in:
Nocturn9x 2021-11-17 21:14:41 +01:00
parent 2582d18596
commit 93fdb6bd10
1 changed files with 4 additions and 0 deletions

View File

@ -609,6 +609,10 @@ proc compile*(self: Compiler, ast: seq[ASTNode], file: string): Chunk =
self.current = 0
while not self.done():
self.declaration(self.step())
while self.staticNames.len() > 0:
# Gets rid of statically resolved locals
self.emitByte(Pop)
discard self.staticNames.pop()
if self.ast.len() > 0:
# *Technically* an empty program is a valid program
self.emitByte(OpCode.Return) # Exits the VM's main loop when used at the global scope