mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 10:01:13 +09:00
LibJS: Allow function calls with missing arguments
We were interpreting "undefined" as a variable lookup failure in some cases and throwing a ReferenceError exception instead of treating it as the valid value "undefined". This patch wraps the result of variable lookup in Optional<>, which allows us to only throw ReferenceError when lookup actually fails.
This commit is contained in:
parent
04ced9e24a
commit
c60dc84a33
Notes:
sideshowbarker
2024-07-19 08:06:31 +09:00
Author: https://github.com/awesomekling
Commit: c60dc84a33
7 changed files with 45 additions and 10 deletions
13
Libraries/LibJS/Tests/function-missing-arg.js
Normal file
13
Libraries/LibJS/Tests/function-missing-arg.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
function foo(a, b) { return a + b; }
|
||||
|
||||
try {
|
||||
assert(isNaN(foo()) === true);
|
||||
assert(isNaN(foo(1)) === true);
|
||||
assert(foo(2, 3) === 5);
|
||||
assert(foo(2, 3, 4) === 5);
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
console.log("FAIL: " + e);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue