Fix the indexing of Array builtin functions. by bzsolt · Pull Request #196 · jerryscript-project/jerryscript · GitHub
Skip to content

Fix the indexing of Array builtin functions. - #196

Closed
bzsolt wants to merge 1 commit into
jerryscript-project:masterfrom
bzsolt:fix_array_builtin_indexing
Closed

bzsolt wants to merge 1 commit into
jerryscript-project:masterfrom
bzsolt:fix_array_builtin_indexing

Conversation

@bzsolt

@bzsolt bzsolt commented Jun 16, 2015

Copy link
Copy Markdown
Member

The index-dependant builtins didn't handle correctly the positive Infinity value.

JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could you, please, move the function to jerry-core/ecma/builtin-objects/ecma-builtin-helpers.cpp, as this is a helper for built-ins implementation?

Could you also, please, add more detailed comment about what is normalized index and "See also" section, listing built-in routines that use the helper?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Of course, I've updated the PR.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thank you.

@egavrin egavrin added bug Undesired behaviour ecma builtins Related to ECMA built-in routines labels Jun 16, 2015
@egavrin egavrin added this to the ECMA builtins milestone Jun 16, 2015

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rename k to smth more meaningful, please.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed.

@galpeter

Copy link
Copy Markdown
Contributor

The string prototype was also modified in this PR, but there is no test for it. Also the title of the commit/PR does not reflect that the string was also modified.

@bzsolt

bzsolt commented Jun 17, 2015

Copy link
Copy Markdown
Member Author

Yes, because this bug only occured in Array.prototype, in String.prototype I just replaced the clamping part to call the clamper function. This replace didn't changed the functionality of String.prototype.slice().
In String.prototype.slice() the positive Infinity index was handled correctly.
The string-prototype-slice.js covers these cases, therefore I haven't added additional testcases.

@galpeter

Copy link
Copy Markdown
Contributor

@bzsolt ok, thanks for the info.

@galpeter

Copy link
Copy Markdown
Contributor

lgtm

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

-int_from_idx

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I am a little bit confused, because I used the requested style in a previous
commit, but it was not proper.
So which is the good one? Is there a coding style for Jerry somewhere?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah, my bad. Last time I was wrong.
Our current style should be the following:

int a = b - c; // subtraction
int a = -a; // negate

PS Actually this checks should be implemented as vera++ rule, but some of rules are missing right now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for the explanation, I've fixed it.

@egavrin

egavrin commented Jun 21, 2015

Copy link
Copy Markdown
Contributor

make push after fixing

The index-dependant builtins didn't handle correctly the positive Infinity value.

JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
@galpeter

Copy link
Copy Markdown
Contributor

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