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

Avoid looking up @@isConcatSpreadable for tuples. #334

Open
acutmore opened this issue Jul 25, 2022 · 1 comment
Open

Avoid looking up @@isConcatSpreadable for tuples. #334

acutmore opened this issue Jul 25, 2022 · 1 comment
Milestone

Comments

@acutmore
Copy link
Collaborator

Right now the spec will check @@isConcatSpreadable on Tuple.prototype when passed a tuple, before defaulting to returning true for tuples:

1. If Type(O) is not Object or Tuple, return false.
2. Let spreadable be ? GetV(O, @@isConcatSpreadable).
3. If spreadable is not undefined, return ! ToBoolean(spreadable).
4. If ! IsTuple(O), return true.
5. Return ? IsArray(O).

This means that if someone creates Tuple.prototype[Symbol.isConcatSpreadable] and returns false, it would change how Tuples behave in concat. It might make sense to do an early return for IsTuple and always return true - keeping the behavior 'static'.

cc: @michaelficarra

@rricard rricard mentioned this issue Jul 25, 2022
25 tasks
@ljharb
Copy link
Member

ljharb commented Jul 26, 2022

It would be confusing if someone did that, and Tuple concat still spreaded tuples but Array concat didnt. If both are hardcoding it, then it would still be confusing that primitive Tuple spread but boxed tuples dont.

I think they should just be looked up via the symbol.

@acutmore acutmore added this to the stage 3 milestone Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants