Implement Getters and setters for objects #753
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
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:
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 implementedThe text was updated successfully, but these errors were encountered: