You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
is this intended behavior?
global variables get skipped in the resolver because there is no scope on the stack (in
declare()
anddefine()
)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
and im getting these parse errors in my implementation for this example
The text was updated successfully, but these errors were encountered: