Skip to content

Fix Array.prototype.concat() when 'this' is not an array. #415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2015

Conversation

dbatyai
Copy link
Member

@dbatyai dbatyai commented Jul 16, 2015

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai.u-szeged@partner.samsung.com

@dbatyai dbatyai added bug Undesired behaviour ecma builtins Related to ECMA built-in routines labels Jul 16, 2015
@dbatyai dbatyai added this to the ECMA builtins milestone Jul 16, 2015
@@ -113,24 +113,40 @@ ecma_builtin_array_prototype_object_concat (ecma_value_t this_arg, /**< this arg
ecma_completion_value_t new_array = ecma_op_create_array_object (0, 0, false);
ecma_object_t *new_array_p = ecma_get_object_from_completion_value (new_array);

if (ecma_object_get_class_name (obj_p) == LIT_MAGIC_STRING_ARRAY_UL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbatyai, could you, please, add comments with steps from specification that correspond to the operations?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_value,
false);
JERRY_ASSERT (ecma_is_completion_value_normal (put_comp));
ecma_free_completion_value (put_comp);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As is_throw argument of ecma_op_object_put is false, exceptions can't be thrown and only possible return values in the case are "simple true" or "simple false".
So, we can replace this with corresponding assertion and remove ecma_free_completion_value call.

@dbatyai dbatyai force-pushed the array_concat_obj_this branch 2 times, most recently from f0500cb to a407d31 Compare July 20, 2015 13:58
@dbatyai
Copy link
Member Author

dbatyai commented Jul 20, 2015

@ruben-ayrapetyan, I've updated the patch.

@dbatyai dbatyai assigned ruben-ayrapetyan and unassigned dbatyai Jul 20, 2015
*/
ecma_completion_value_t
ecma_builtin_helper_array_concat_value (ecma_object_t *obj_p, /**< array */
uint32_t *length, /**< in-out: array's length */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add _p suffix.

@ruben-ayrapetyan
Copy link
Contributor

@dbatyai, thank you for update.

@ruben-ayrapetyan
Copy link
Contributor

After fixing #415 (comment) the changes would look good to me

@ruben-ayrapetyan
Copy link
Contributor

Looks good to me

@ruben-ayrapetyan ruben-ayrapetyan assigned egavrin and unassigned dbatyai Jul 20, 2015
@galpeter
Copy link
Contributor

looks good to me

@dbatyai dbatyai force-pushed the array_concat_obj_this branch from 8d7789f to 046833c Compare July 22, 2015 13:32
@egavrin
Copy link
Contributor

egavrin commented Jul 24, 2015

Could you please rebase it to master - I'm getting conflicts at merging.

@egavrin egavrin removed their assignment Jul 24, 2015
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai.u-szeged@partner.samsung.com
@dbatyai dbatyai force-pushed the array_concat_obj_this branch from 046833c to 9513808 Compare July 24, 2015 08:12
@dbatyai
Copy link
Member Author

dbatyai commented Jul 24, 2015

@egavrin, rebased to master.

@dbatyai dbatyai assigned egavrin and unassigned dbatyai Jul 24, 2015
@egavrin egavrin merged commit 9513808 into jerryscript-project:master Jul 24, 2015
@dbatyai dbatyai deleted the array_concat_obj_this branch July 31, 2015 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Undesired behaviour ecma builtins Related to ECMA built-in routines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants