Search code examples
javascriptnode.jsgoogle-chromev8

Why does V8 give this confusing error message?


On chrome/node (v8 in general i suppose), the following gives an error message:

Uncaught TypeError: f is not iterable

function f(){}
f(...undefined);

Why does it generate such an ambiguous error message? Imho, this has nothing to do with f?

E.g. on firefox (spidermonkey), i get an understandable "undefined has no properties". If i use an object (let o = {}; f(...o.p);), i get an even more accurate "o.p is undefined".

This has probably been asked before, but i have no clue what to search for - "function not iterable" gives a ton unrelated results.

PS: just as a fun fact, obviously, the error will not go away, if f is made iterable: f[Symbol.iterator] = function*() {};. The error message seems to be plain wrong.


Solution

  • V8 developer here. This looks like a bug. Please file a bug at crbug.com/v8/new.