mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
js: Fix simple scopes example
Weirdly enough, the "simple-scopes" test doesn't return undefined anymore, at first I thought the scoping was somehow broken, turns out the interpreter doesn't consider the returned y as the last evaluated value anymore, possibly because it's undefined (?).
This commit is contained in:
parent
dfbaa8e543
commit
6780d70fb1
Notes:
sideshowbarker
2024-07-19 08:16:41 +09:00
Author: https://github.com/0xtechnobabble Commit: https://github.com/SerenityOS/serenity/commit/6780d70fb18 Pull-request: https://github.com/SerenityOS/serenity/pull/1470 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/oriko1010
1 changed files with 4 additions and 2 deletions
|
@ -1,9 +1,11 @@
|
|||
//I should return `undefined` because y is bound to the inner-most enclosing function, i.e the nested one (bar()), therefore, it's undefined in the scope of foo()
|
||||
function foo() {
|
||||
function bar() {
|
||||
var y = 6;
|
||||
}
|
||||
|
||||
bar()
|
||||
bar();
|
||||
return y;
|
||||
}
|
||||
foo(); //I should return `undefined` because y is bound to the inner-most enclosing function, i.e the nested one (bar()), therefore, it's undefined in the scope of foo()
|
||||
|
||||
print(foo());
|
||||
|
|
Loading…
Add table
Reference in a new issue