Fix assert in ecma_op_function_declaration
Minor code rework as the ecma_op_object_define_own_property call returns a 'true' simple value on success. JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
This commit is contained in:
@@ -902,14 +902,14 @@ ecma_op_function_declaration (ecma_object_t *lex_env_p, /**< lexical environment
|
||||
// c.
|
||||
bool func_already_declared = ecma_op_has_binding (lex_env_p, function_name_p);
|
||||
|
||||
// d.
|
||||
ecma_completion_value_t completion = ecma_make_empty_completion_value ();
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
// d.
|
||||
if (!func_already_declared)
|
||||
{
|
||||
completion = ecma_op_create_mutable_binding (lex_env_p,
|
||||
function_name_p,
|
||||
is_configurable_bindings);
|
||||
ecma_completion_value_t completion = ecma_op_create_mutable_binding (lex_env_p,
|
||||
function_name_p,
|
||||
is_configurable_bindings);
|
||||
|
||||
JERRY_ASSERT (ecma_is_completion_value_empty (completion));
|
||||
}
|
||||
@@ -937,14 +937,15 @@ ecma_op_function_declaration (ecma_object_t *lex_env_p, /**< lexical environment
|
||||
property_desc.is_configurable = is_configurable_bindings;
|
||||
}
|
||||
|
||||
completion = ecma_op_object_define_own_property (glob_obj_p,
|
||||
function_name_p,
|
||||
&property_desc,
|
||||
true);
|
||||
ecma_completion_value_t completion = ecma_op_object_define_own_property (glob_obj_p,
|
||||
function_name_p,
|
||||
&property_desc,
|
||||
true);
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal_true (completion));
|
||||
}
|
||||
else if (existing_prop_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
|
||||
{
|
||||
completion = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -953,29 +954,25 @@ ecma_op_function_declaration (ecma_object_t *lex_env_p, /**< lexical environment
|
||||
if (!ecma_is_property_writable (existing_prop_p)
|
||||
|| !ecma_is_property_enumerable (existing_prop_p))
|
||||
{
|
||||
completion = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
}
|
||||
|
||||
ecma_deref_object (glob_obj_p);
|
||||
}
|
||||
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
if (ecma_is_completion_value_throw (completion))
|
||||
if (ecma_is_completion_value_empty (ret_value))
|
||||
{
|
||||
ret_value = completion;
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_completion_value_empty (completion));
|
||||
|
||||
// f.
|
||||
ret_value = ecma_op_set_mutable_binding (lex_env_p,
|
||||
function_name_p,
|
||||
ecma_make_object_value (func_obj_p),
|
||||
is_strict);
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_completion_value_throw (ret_value));
|
||||
}
|
||||
|
||||
ecma_deref_object (func_obj_p);
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
// Copyright 2015 University of Szeged.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
function Error() { }
|
||||
Reference in New Issue
Block a user