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

Ensure correct behavior of Tuple methods that refer to the definition of Array methods #323

Closed
nicolo-ribaudo opened this issue Jul 13, 2022 · 1 comment · Fixed by #362

Comments

@nicolo-ribaudo
Copy link
Member

Some of the tuple methods, such as Tuple.prototype.map, are defined with explicit steps and, when they have a callback, they pass the result of thisTupleValue(this) as the last parameter.
Other tuple methods, such as Tuple.prototype.forEach, are defined as a diff from the relative Array method, with references to this replaced with thisTupleVaue(this). However, array methods call ToObject(this) (which thus ends up being ToObject(thisTupleVaue(this)))) and pass the resulting object as the last parameter to the callback function.

In practice, this means that #[1].forEach((v, i, tup) => console.log(typeof tup)) logs "object" instead of "tuple": we should fix how we define those methods to make sure that the last parameter is correctly a primitive tuple.

Ref #317 (comment)

@ljharb
Copy link
Member

ljharb commented Jul 13, 2022

I think the longer term approach is to actually have explicit spec steps instead of the indirect "x, but replace step y with z" approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants