-
Notifications
You must be signed in to change notification settings - Fork 677
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
Array.prototype.reduce() #104
Array.prototype.reduce() #104
Conversation
JerryScript-DCO-1.0-Signed-off-by: Laszlo Vidacs [email protected]
JerryScript-DCO-1.0-Signed-off-by: Laszlo Vidacs [email protected]
JerryScript-DCO-1.0-Signed-off-by: Laszlo Vidacs [email protected]
Just briefly checked, seems ok. |
if (len_number == ECMA_NUMBER_ZERO && ecma_is_value_undefined (arg1)) | ||
{ | ||
ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code following this should be in the else
case of the condition I think.
JerryScript-DCO-1.0-Signed-off-by: Laszlo Vidacs [email protected]
The code is updated according to review comments. |
assert(e instanceof TypeError); | ||
} | ||
|
||
// various checks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have a check for empty array + no/undefined initialValue to see if that results a TypeError as described in the 5th step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is in lines 28-35 with empty array + no initial value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh... true :) sorry
lgtm |
ecma_number_t *num_p = ecma_alloc_number (); | ||
ecma_object_t *func_object_p; | ||
|
||
ecma_completion_value_t to_object_comp = ecma_op_to_object (arg1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to perform the conversion, since ecma_op_is_callable
returned true for the value.
So, we could just assert that ecma_is_value_object
and perform ecma_get_object_from_value
.
Thanks for the detailed review, the patch is updated. |
JerryScript-DCO-1.0-Signed-off-by: Laszlo Vidacs [email protected]
e45bc7c
to
35441b7
Compare
|
Rebased & merged in: 89e5444 |
JerryScript-DCO-1.0-Signed-off-by: Laszlo Vidacs [email protected]