Everything is a closure
Some checks failed
Build / build (push) Failing after 1m56s
Test / build (push) Failing after 2m33s

This commit is contained in:
Chuck Smith
2024-03-13 17:08:17 -04:00
parent e373e9f68a
commit 78b560e457
7 changed files with 132 additions and 81 deletions

View File

@@ -292,7 +292,9 @@ func (c *Compiler) Compile(node ast.Node) error {
NumLocals: numLocals,
NumParameters: len(node.Parameters),
}
c.emit(code.OpConstant, c.addConstant(compiledFn))
fnIndex := c.addConstant(compiledFn)
c.emit(code.OpClosure, fnIndex, 0)
case *ast.ReturnStatement:
err := c.Compile(node.ReturnValue)