-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
is this intended behavior?
global variables get skipped in the resolver because there is no scope on the stack (in declare()
and define()
)
when accessing a global variable in a new scope (function or loop for example) in visitVariableExpr()
, there is a scope on the stack. so it will check if if the variable is defined, which it is not. scopes.peek().get(expr.name.lexeme) == Boolean.FALSE
it will then report a parse error Lox.error(expr.name, "Can't read local variable in its own initializer.");
is this intended during (and/or after) chapter 11? this for example does not work
var a = 0;
for (var i = 0; i < 10; i = i + 1) {
print a;
}
and im getting these parse errors in my implementation for this example
[line 4] Error at 'a': Can't read local variable in its own initializer.
[line 3] Error at 'i': Can't read local variable in its own initializer.
Activity