HasInstance should accept the prototype of all functions. Fixes #1519. (#1520)

The regression-test-issue-736.js is also changed, since it expects
throwing an error, which does not happen anymore because the "x"
variable is undefined.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2017-01-16 13:43:54 +01:00
committed by Tilmann Scheller
parent 6e5b759319
commit 4b5cf8ad26
3 changed files with 47 additions and 13 deletions
@@ -366,14 +366,9 @@ ecma_op_function_has_instance (ecma_object_t *func_obj_p, /**< Function object *
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
if (ecma_get_object_type (func_obj_p) == ECMA_OBJECT_TYPE_FUNCTION)
if (ecma_get_object_type (func_obj_p) == ECMA_OBJECT_TYPE_FUNCTION
|| ecma_get_object_type (func_obj_p) == ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION)
{
if (ecma_get_object_is_builtin (func_obj_p)
&& ecma_builtin_function_is_routine (func_obj_p))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Function parameter cannot be built-in a function."));
}
if (!ecma_is_value_object (value))
{
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE);
@@ -389,7 +384,7 @@ ecma_op_function_has_instance (ecma_object_t *func_obj_p, /**< Function object *
if (!ecma_is_value_object (prototype_obj_value))
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Expected an object."));
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Object expected."));
}
else
{
@@ -419,10 +414,6 @@ ecma_op_function_has_instance (ecma_object_t *func_obj_p, /**< Function object *
ecma_deref_ecma_string (prototype_magic_string_p);
}
else if (ecma_get_object_type (func_obj_p) == ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION)
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Expected a function."));
}
else
{
JERRY_ASSERT (ecma_get_object_type (func_obj_p) == ECMA_OBJECT_TYPE_BOUND_FUNCTION);