From 6cd309b5252d15f3e3e6481c72a4d8fa7f9557a9 Mon Sep 17 00:00:00 2001 From: Robert Fancsik Date: Fri, 22 May 2020 17:23:07 +0200 Subject: [PATCH] Function.prototype[@@hasInstance] should not throw error for not callable this value (#3773) JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu --- .../ecma/builtin-objects/ecma-builtin-function-prototype.c | 7 +++++++ tests/test262-es6-excludelist.xml | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-function-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-function-prototype.c index ad510e71f..c8ea48cd9 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-function-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-function-prototype.c @@ -392,6 +392,13 @@ ecma_builtin_function_prototype_dispatch_routine (uint16_t builtin_routine_id, / { if (!ecma_op_is_callable (this_arg)) { +#if ENABLED (JERRY_ES2015) + if (JERRY_UNLIKELY (builtin_routine_id == ECMA_FUNCTION_PROTOTYPE_SYMBOL_HAS_INSTANCE)) + { + return ECMA_VALUE_FALSE; + } +#endif /* ENABLED (JERRY_ES2015) */ + return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a function.")); } diff --git a/tests/test262-es6-excludelist.xml b/tests/test262-es6-excludelist.xml index b23fa565d..81715821a 100644 --- a/tests/test262-es6-excludelist.xml +++ b/tests/test262-es6-excludelist.xml @@ -1,4 +1,4 @@ - + @@ -68,7 +68,6 @@ -