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

[exec Array] implement spread operator using iterator #811

Merged
merged 5 commits into from
Oct 11, 2020

Conversation

croraf
Copy link
Contributor

@croraf croraf commented Oct 7, 2020

This Pull Request fixes #793

It changes the following:

@Razican
Copy link
Member

Razican commented Oct 9, 2020

Hey! thanks for this contribution. It seems it requires a re-base to fix one issue we were having in the test262 test suite :)

@codecov
Copy link

codecov bot commented Oct 9, 2020

Codecov Report

Merging #811 into master will decrease coverage by 0.11%.
The diff coverage is 77.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #811      +/-   ##
==========================================
- Coverage   59.37%   59.26%   -0.12%     
==========================================
  Files         157      157              
  Lines       10036    10040       +4     
==========================================
- Hits         5959     5950       -9     
- Misses       4077     4090      +13     
Impacted Files Coverage Δ
boa/src/context.rs 61.71% <ø> (-5.41%) ⬇️
boa/src/syntax/ast/node/array/mod.rs 74.07% <77.77%> (+0.16%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e82dee1...84116d2. Read the comment docs.

Copy link
Member

@Razican Razican left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me. Check if the mentioned changes make sense.

boa/src/builtins/map/tests.rs Outdated Show resolved Hide resolved
Comment on lines 44 to 47
//not sure what to do with this next_index mentioned in the spec
//it is mentioned that it has to be returned from somewhere
//https://tc39.es/ecma262/#sec-runtime-semantics-arrayaccumulation
//let mut next_index = 0;
Copy link
Member

Choose a reason for hiding this comment

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

This is basically because we don't follow the spec with arrays. The thing is, arrays have a number of integer-indexed elements, and a nextIndex. this nextIndex will be the same as array.length, and it's defined here: https://tc39.es/ecma262/#sec-array-initializer-runtime-semantics-evaluation

But, due to our array being a vector (which causes performance issues), we don't have this defined. This is partially the reason behind ##816. This means that if we for example create a huge empty array (which should not allocate), say new Array(50000), we will have huge performance issues.

This also means that if we do something like let a = [5,6,,,6,7,,8];, we will have an undefined value in the non-defined slots, but they should instead be empty slots, and here, nextIndex would be 8 (same as length).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you suggest? Should we leave this comment and commented next_index, or modify the comment, or remove completly?

Copy link
Member

Choose a reason for hiding this comment

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

I would change the comment to a TODO, explaing this is waiting for a proper internal Array representation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please check the newly committed rewording.

@HalidOdat HalidOdat added bug Something isn't working builtins PRs and Issues related to builtins/intrinsics execution Issues or PRs related to code execution labels Oct 10, 2020
@HalidOdat HalidOdat added this to the v0.11.0 milestone Oct 10, 2020
@HalidOdat HalidOdat merged commit 4e41b44 into boa-dev:master Oct 11, 2020
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 execution Issues or PRs related to code execution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spread operator on a non-iterable panics
4 participants