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

The Array() constructor is not spec compliant #816

Closed
Razican opened this issue Oct 8, 2020 · 2 comments · Fixed by #859
Closed

The Array() constructor is not spec compliant #816

Razican opened this issue Oct 8, 2020 · 2 comments · Fixed by #859
Assignees
Labels
bug Something isn't working builtins PRs and Issues related to builtins/intrinsics good first issue Good for newcomers Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com
Milestone

Comments

@Razican
Copy link
Member

Razican commented Oct 8, 2020

Describe the bug
The Array() constructor is not spec compliant. When creating a huge array, for example:

let a = new Array(50000);

This will try to actually insert 50k properties in the array. The spec says otherwise. It should only set the length, and should not create any other property.

This happens because our implementation is not spec compliant. We should have 3 private constructor methods (construct_array, construct_array_length and construct_array_items), and they should be called from the constructor method. In each of them, we should have information about the exact spec, and use the actual spec implementation.

This means we will need to create an array_create function, that will follow this spec.

A similar thing should be done with the rest of the Array prototype methods.

@Razican Razican added bug Something isn't working good first issue Good for newcomers Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com builtins PRs and Issues related to builtins/intrinsics labels Oct 8, 2020
@Razican Razican added this to the v0.11.0 milestone Oct 8, 2020
@Razican Razican mentioned this issue Oct 8, 2020
@georgeroman
Copy link
Contributor

I can take this one.

@Razican
Copy link
Member Author

Razican commented Oct 9, 2020

I can take this one.

Go ahead! :D let us know if you need guidance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working builtins PRs and Issues related to builtins/intrinsics good first issue Good for newcomers Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants