Fix Reflect.getPrototypeOf for primitive arguments (#3354)

Fixes #3349.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
This commit is contained in:
Dániel Bátyai 2019-11-25 11:49:04 +01:00 committed by Robert Fancsik
parent 1c6f334f62
commit b2d34724d4
2 changed files with 15 additions and 2 deletions

View File

@ -77,8 +77,7 @@ ecma_builtin_reflect_dispatch_routine (uint16_t builtin_routine_id, /**< built-i
JERRY_UNUSED (this_arg);
JERRY_UNUSED (arguments_number);
if (!ecma_is_value_object (arguments_list[0])
&& builtin_routine_id > ECMA_REFLECT_OBJECT_SET_PROTOTYPE_OF_UL)
if (!ecma_is_value_object (arguments_list[0]))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument is not an Object."));
}

View File

@ -15,3 +15,17 @@
assert (Reflect['getPrototypeOf']({}) === Object.prototype);
assert (Reflect['getPrototypeOf'](Object.create(null)) === null);
assert (Reflect['getPrototypeOf'](Object.prototype) === null);
try {
Reflect.getPrototypeOf();
assert (false);
} catch (e) {
assert (e instanceof TypeError);
}
try {
Reflect.getPrototypeOf("str");
assert (false);
} catch (e) {
assert (e instanceof TypeError);
}