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

wrong error on destructing assignment #11376

Closed
dimitriylol opened this issue Feb 14, 2017 · 3 comments
Closed

wrong error on destructing assignment #11376

dimitriylol opened this issue Feb 14, 2017 · 3 comments
Labels
v8 engine Issues and PRs related to the V8 dependency.

Comments

@dimitriylol
Copy link

dimitriylol commented Feb 14, 2017

Destructuring assignment array on object instance produces a TypeError with an incorrect message.
Code that demonstrates the problem:

function foo () { return { a: 10 }; }
const [ first, second ] = foo();
TypeError: foo is not a function
    at repl:1:27
    at sigintHandlersWrap (vm.js:32:31)
    at sigintHandlersWrap (vm.js:96:12)
    at ContextifyScript.Script.runInContext (vm.js:31:12)
    at REPLServer.defaultEval (repl.js:308:29)
    at bound (domain.js:280:14)
    at REPLServer.runBound [as eval] (domain.js:293:12)
    at REPLServer.<anonymous> (repl.js:489:10)
    at emitOne (events.js:101:20)
    at REPLServer.emit (events.js:188:7)

Please, clarify, is it possible to produce error without mentioning function name?

@jasnell
Copy link
Member

jasnell commented Feb 14, 2017

That is quite odd. Chrome does the exact same thing so it's definitely a V8 thing. Whether or not it's a bug or intended behavior we'll have to leave it for the @nodejs/v8 team to figure out. @fhinkel thoughts?

@jasnell jasnell added the v8 engine Issues and PRs related to the V8 dependency. label Feb 14, 2017
@fhinkel
Copy link
Member

fhinkel commented Feb 15, 2017

var [ x, y ] = {a: 10}
Uncaught TypeError: undefined is not a function
    at <anonymous>:1:1

Oh yes, the error message is not helpful. Something like {a:1} is not iterable would be much better. @dimitriylol thanks for reporting! Do you mind heading over to V8's issue tracker and reporting it there?

@fhinkel fhinkel closed this as completed Feb 15, 2017
@dimitriylol
Copy link
Author

@fhinkel I created issue 5973 on V8's issue tracker.
Thanks for quick response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

No branches or pull requests

3 participants