Skip to content
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

Fix assert in Object.defineProperties function #137

Merged
merged 1 commit into from
Jun 10, 2015
Merged

Fix assert in Object.defineProperties function #137

merged 1 commit into from
Jun 10, 2015

Conversation

kkristof
Copy link
Contributor

@kkristof kkristof commented Jun 1, 2015

JerryScript-DCO-1.0-Signed-off-by: Kristof Kosztyo [email protected]

@galpeter
Copy link
Contributor

galpeter commented Jun 1, 2015

Please reference the related issue somewhere.

@kkristof
Copy link
Contributor Author

kkristof commented Jun 1, 2015

Fix for issue #131

@@ -333,7 +333,7 @@ ecma_builtin_object_object_define_properties (ecma_value_t this_arg __attr_unuse
{
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();

if (!ecma_is_value_object (arg1))
if (!ecma_is_value_object (arg1) || !ecma_is_value_object (arg2))
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you, please, update implementation to follow ECMA-defined pseudocode?

In the ECMA description of the procedure there is no type check, there is ToObject conversion.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also, please, add comments with step numbers according to ECMA pseudocode, like // 5.c?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as part of the refactoring I'm going to do this as well

@ruben-ayrapetyan ruben-ayrapetyan self-assigned this Jun 1, 2015
@ruben-ayrapetyan ruben-ayrapetyan added this to the ECMA builtins milestone Jun 1, 2015
@ruben-ayrapetyan ruben-ayrapetyan added bug Undesired behaviour normal ecma builtins Related to ECMA built-in routines labels Jun 1, 2015
@kkristof
Copy link
Contributor Author

kkristof commented Jun 2, 2015

I'm refactoring this function because we've found some corner cases where the actual result differs from the expected.

@kkristof
Copy link
Contributor Author

kkristof commented Jun 5, 2015

Hi, I have updated the patch.


if (!ecma_is_completion_value_throw (ret_value))
{
property_descriptor_number++;
Copy link
Contributor

Choose a reason for hiding this comment

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

The line could be moved to line 471, and the if could be removed then.

@kkristof
Copy link
Contributor Author

kkristof commented Jun 8, 2015

Hi, I have updated the patch.

@egavrin egavrin assigned egavrin and ruben-ayrapetyan and unassigned kkristof and egavrin Jun 8, 2015
@kkristof
Copy link
Contributor Author

kkristof commented Jun 8, 2015

I've added your test case to the test.

@ruben-ayrapetyan
Copy link
Contributor

@kkristof, great.

What about adding test for 'properties object with getter property that throws exception upon execution;'?

@kkristof
Copy link
Contributor Author

kkristof commented Jun 8, 2015

This isn't that case?
tests/jerry/object_define_properties.js:126

@ruben-ayrapetyan
Copy link
Contributor

This isn't that case?
tests/jerry/object_define_properties.js:126

No.
Please, see the comment: #137 (comment) .

By 'properties object with getter property' I mean getter property in the properties object itself, i.e.:

In the comment, I didn't asked you to add additional test case, but to update the tests cases that you have already added.

So,

Could you, please, add the following test cases?
- properties object with accessor property definition;
- properties object with getter property that throws exception upon execution;
- properties object with getter property that deletes properties of properties object.

Currently, we have tests for first and third case, but not for the second.
Could you, please, add the test too?

@kkristof
Copy link
Contributor Author

kkristof commented Jun 9, 2015

Hi, I have updated the test.

@ruben-ayrapetyan
Copy link
Contributor

Looks good to me.

uint32_t index = 0;
for (property_p = ecma_get_property_list (props_p);
property_p != NULL;
property_p = ECMA_GET_POINTER (ecma_property_t, property_p->next_property_p), index++)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the index here at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, we don't. thank you :)

@kkristof
Copy link
Contributor Author

Hi, I have updated the branch, but I haven't renamed the props_p to something else.

@galpeter
Copy link
Contributor

looks good to me. @ruben-ayrapetyan what do you think?


uint32_t index = 0;
for (property_p = ecma_get_property_list (props_p);
property_p != NULL && ecma_is_completion_value_empty (ret_value);
Copy link
Contributor

Choose a reason for hiding this comment

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

The && ecma_is_completion_value_empty (ret_value) condition part seems not to be necessary, as ret_value is not changed in the loop.

@ruben-ayrapetyan
Copy link
Contributor

looks good to me. @ruben-ayrapetyan what do you think?

After removing the unnecessary condition part (#137 (diff)), the changes would be ok.

Fix assert and corner cases in Object.defineProperties function.

JerryScript-DCO-1.0-Signed-off-by: Kristof Kosztyo [email protected]
@kkristof
Copy link
Contributor Author

Hi, I have updated the patch.

@ruben-ayrapetyan
Copy link
Contributor

Looks good to me

@egavrin
Copy link
Contributor

egavrin commented Jun 10, 2015

make push

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 normal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants