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

Object internal methods don't have Receiver parameter #1040

Closed
RageKnify opened this issue Jan 5, 2021 · 2 comments · Fixed by #1042
Closed

Object internal methods don't have Receiver parameter #1040

RageKnify opened this issue Jan 5, 2021 · 2 comments · Fixed by #1042
Assignees
Labels
bug Something isn't working builtins PRs and Issues related to builtins/intrinsics
Milestone

Comments

@RageKnify
Copy link
Contributor

A lot of object internal methods include a parameter named Receiver in the spec, i.e. [[Get]]. As an example we have the code:

let o = {}
let o2 = {}
Object.defineProperty(o, 't', {
  set: function(arg) {
    console.log(arg)
  },
});

Reflect.set(o, 't', 3)
Reflect.set(o, 't', 3, o2)

o2.t should remain undefined and console.log(3) should be invoked but instead it becomes 3 and console.log is not invoked.
This should be possible with the code in #1033 but with current implementation of [[Get]] it is not possible.

[[Get]]:

/// `[[Get]]`
/// <https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver>
pub fn get(&self, key: &PropertyKey, context: &mut Context) -> Result<Value> {

[[Set]]:

/// `[[Set]]`
/// <https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-set-p-v-receiver>
pub fn set(&mut self, key: PropertyKey, val: Value, context: &mut Context) -> Result<bool> {

Only other instances I can find in the spec are for exotic objects, which I don't think are currently implemented.

@RageKnify RageKnify added bug Something isn't working builtins PRs and Issues related to builtins/intrinsics labels Jan 5, 2021
@RageKnify RageKnify added this to the v0.11.0 milestone Jan 5, 2021
@tofpie
Copy link
Contributor

tofpie commented Jan 5, 2021

@RageKnify Can I take it?

@RageKnify
Copy link
Contributor Author

Go ahead @tofpie 🎉

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants