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

Implement Spread operator for Objects #214

Closed
jasonwilliams opened this issue Dec 3, 2019 · 2 comments · Fixed by #1364
Closed

Implement Spread operator for Objects #214

jasonwilliams opened this issue Dec 3, 2019 · 2 comments · Fixed by #1364
Assignees
Labels
E-Medium Medium difficulty problem enhancement New feature or request good first issue Good for newcomers Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com help wanted Extra attention is needed
Milestone

Comments

@jasonwilliams
Copy link
Member

jasonwilliams commented Dec 3, 2019

The rest operator has been implemented to arrays. [a,b,...c]
But it is not implemented for objects.

test case

const b = {
  a: 1,
  b: 2,
  c: 3
};

const a = {
  a: "a",
  b: "b",
  ...b
};

console.log(a);

The array implementation exists here inside of exec.rs:
https://github.com/jasonwilliams/boa/blob/master/src/lib/exec.rs#L218-L223

Tests for this exist here too:
https://github.com/jasonwilliams/boa/blob/master/src/lib/exec.rs#L850-L862

https://github.com/jasonwilliams/boa/blob/master/src/lib/exec.rs#L202-L213 will need to do something similar.

There will need to be changes to the parser so spread can be parsed within an object. The above code will currently error in the parser as spread syntax isn't expecting within an object.
Parsing objects happens here:
https://github.com/jasonwilliams/boa/blob/master/src/lib/syntax/parser.rs#L522-L574

@jasonwilliams jasonwilliams added enhancement New feature or request help wanted Extra attention is needed labels Dec 3, 2019
@gomesalexandre
Copy link
Contributor

Will take a look at this one soon

@jasonwilliams jasonwilliams added good first issue Good for newcomers Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com E-Medium Medium difficulty problem labels Sep 28, 2020
@FrancisMurillo
Copy link
Contributor

Can I take this?

@Razican Razican added this to the v0.13.0 milestone Jun 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-Medium Medium difficulty problem enhancement New feature or request good first issue Good for newcomers Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants