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

No runtime error for spreading non-iterables #2160

Closed
webbedspace opened this Issue Aug 5, 2015 · 3 comments

Comments

Projects
None yet
6 participants
@webbedspace

webbedspace commented Aug 5, 2015

console.log([...2]); produces code which outputs an empty array, instead of throwing a runtime error. (Whether or not this is capable of being fixed is unknown to me.)

@zloirock

This comment has been minimized.

Show comment
Hide comment
@zloirock

zloirock Aug 5, 2015

Member

Currently spread in babel uses Array.from. Array.from different from spread support array-like objects. Possible add checking Symbol.iterator in it ? Array.from(it) : throwError(), but it will create problems with arguments - by spec it should be iterable, but we can't add Symbol.iterator to arguments prototype - it's Object.prototype. Someone can use [...arguments].

Member

zloirock commented Aug 5, 2015

Currently spread in babel uses Array.from. Array.from different from spread support array-like objects. Possible add checking Symbol.iterator in it ? Array.from(it) : throwError(), but it will create problems with arguments - by spec it should be iterable, but we can't add Symbol.iterator to arguments prototype - it's Object.prototype. Someone can use [...arguments].

@hzoo

This comment has been minimized.

Show comment
Hide comment
@hzoo

hzoo Sep 12, 2016

Member

Can we just check for arguments?

Related #2426

Member

hzoo commented Sep 12, 2016

Can we just check for arguments?

Related #2426

@ljharb

This comment has been minimized.

Show comment
Hide comment
@ljharb

ljharb May 16, 2017

[...function* () {}] is another example.

ljharb commented May 16, 2017

[...function* () {}] is another example.

@existentialism existentialism modified the milestones: Babel 7.next, Babel 7 Jul 25, 2017

@lock lock bot added the outdated label Jun 7, 2018

@lock lock bot locked as resolved and limited conversation to collaborators Jun 7, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.