mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-29 07:48:47 +00:00
"var" declarations are hoisted to the nearest function scope, while "let" and "const" are hoisted to the nearest block scope. This is done by the parser, which keeps two scope stacks, one stack for the current var scope and one for the current let/const scope. When the interpreter enters a scope, we walk all of the declarations and insert them into the variable environment. We don't support the temporal dead zone for let/const yet.
21 lines
323 B
JavaScript
21 lines
323 B
JavaScript
try {
|
|
function foo() {
|
|
i = 3;
|
|
assert(i === 3);
|
|
var i;
|
|
}
|
|
|
|
foo();
|
|
|
|
var caught_exception;
|
|
try {
|
|
j = i;
|
|
} catch (e) {
|
|
caught_exception = e;
|
|
}
|
|
assert(caught_exception !== undefined);
|
|
|
|
console.log("PASS");
|
|
} catch (e) {
|
|
console.log("FAIL: " + e);
|
|
}
|