@ -44,6 +44,14 @@ module Lox
nil
end
def visit_function(stmt)
declare(stmt.name)
define(stmt.name)
resolve_function(stmt)
private
def with_block
@ -74,5 +82,15 @@ module Lox
@interpreter.resolve(expr, depth)
def resolve_function(fn)
with_scope do
fn.params.each do |param|
declare(param)
define(param)
resolve(fn.body)