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 Getters and setters for objects #753

Closed
jasonwilliams opened this issue Oct 1, 2020 · 5 comments
Closed

Implement Getters and setters for objects #753

jasonwilliams opened this issue Oct 1, 2020 · 5 comments
Assignees
Labels
blocked Waiting for another code change E-Hard Hard difficulty problem enhancement New feature or request Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com
Milestone

Comments

@jasonwilliams
Copy link
Member

We support getters and setters in our property descriptors, but we don't do anything with them.
In this example here: https://github.com/boa-dev/boa/blob/master/boa/src/object/internal_methods.rs#L102-L104 we check if a property exists, if it doesn't we should fallback to the getter and call that, but as you can see right now we just return undefined.

There will also need to be some syntax updates to support the get and set inside of objects, im not sure

Spec: https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver
MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get

This code should now work and give the expected result:

let a = {
    get b() {
        return "test";
    }
}

a.b // "test"

Where to start

Running the above right now would give an error and land here:
https://github.com/boa-dev/boa/blob/master/boa/src/exec/object/mod.rs#L29

MethodDefinitionKind::Get would need to be implemented

@jasonwilliams jasonwilliams added enhancement New feature or request good first issue Good for newcomers Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com E-Hard Hard difficulty problem and removed good first issue Good for newcomers labels Oct 1, 2020
@HalidOdat
Copy link
Member

HalidOdat commented Oct 9, 2020

I will be working on the execution part of getters and setters (after some needed refactoring).

@HalidOdat HalidOdat self-assigned this Oct 9, 2020
@HalidOdat HalidOdat added the blocked Waiting for another code change label Oct 10, 2020
@HalidOdat
Copy link
Member

HalidOdat commented Oct 10, 2020

This issue is blocked on:

@Razican
Copy link
Member

Razican commented Jan 11, 2021

I believe this is implemented, right?

/cc @HalidOdat @tofpie

@tofpie
Copy link
Contributor

tofpie commented Jan 11, 2021

As far as I can tell #986 is more or less a duplicate of this one, and it has been solved by #987.

@Razican Razican added this to the v0.11.0 milestone Jan 11, 2021
@Razican
Copy link
Member

Razican commented Jan 11, 2021

As far as I can tell #986 is more or less a duplicate of this one, and it has been solved by #987.

Perfect, let's close this :)

@Razican Razican closed this as completed Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Waiting for another code change E-Hard Hard difficulty problem enhancement New feature or request Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com
Projects
None yet
Development

No branches or pull requests

4 participants