LibJS: Return specified object from Object.setPrototypeOf()

We were leaking an empty value.
This commit is contained in:
Linus Groh 2020-06-02 11:39:24 +01:00 committed by Andreas Kling
parent a60a5bc70a
commit 1a64bdd80c
Notes: sideshowbarker 2024-07-19 05:53:52 +09:00
2 changed files with 13 additions and 1 deletions

View file

@ -103,7 +103,7 @@ Value ObjectConstructor::set_prototype_of(Interpreter& interpreter)
if (interpreter.exception()) if (interpreter.exception())
return {}; return {};
object->set_prototype(&const_cast<Object&>(interpreter.argument(1).as_object())); object->set_prototype(&const_cast<Object&>(interpreter.argument(1).as_object()));
return {}; return object;
} }
Value ObjectConstructor::is_extensible(Interpreter& interpreter) Value ObjectConstructor::is_extensible(Interpreter& interpreter)

View file

@ -0,0 +1,12 @@
load("test-common.js");
try {
assert(Object.setPrototypeOf.length === 2);
o = {};
assert(Object.setPrototypeOf(o, {}) === o);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}