Array destructuring in function parameters results in poor error messages
Reported by
m.go...@gmail.com,
Apr 1 2016
|
||||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36 Steps to reproduce the problem: 1. Enter `var [a] = 2` in the console 2. 3. What is the expected behavior? You should see a message describing a failed destructuring attempt that would say where exactly the problem lies. What went wrong? The error is "undefined is not a function". There's no function involved here so this completely doesn't relate to the actual issue. This is most likely V8 looking for the iterator .next() method & not finding it but that shouldn't surface to the user in this way. Imagine this in a larger piece of code and you looking for a function that doesn't exist where the problem lies in a different place. Did this work before? No Chrome version: 51.0.2696.0 Channel: canary OS Version: OS X 10.11.4 Flash Version: Shockwave Flash 21.0 r0 Firefox displays "TypeError: 2 is not iterable". Safari displays: "TypeError: [a] is not a function. (In '[a]', '[a]' is undefined)" In a larger assignment, like: var [b, [a]] = [2, 3] you'll see: TypeError: [a] is not a function. (In '[a]', '[a]' is undefined) so the place where the problem lies is clear.
,
Apr 4 2016
,
Mar 23 2017
Still 'broken' in Chrome 57 on WIN.
If there is a function involved, it's even more confusing, because the function isn't relevant.
xx = ([a, b]) => console.log(a, b);
xx({x: 4});
Error in Chrome: Uncaught TypeError: undefined is not a function
Error in Firefox: TypeError: (destructured parameter) is not iterable
,
Aug 8 2017
The original report is now fixed, but the report in #c3 looks to still need work (destructuring params don't seem to have a good error message).
,
Aug 8 2017
|
||||
►
Sign in to add a comment |
||||
Comment 1 by dtapu...@chromium.org
, Apr 1 2016