Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 671
Doofus Avatar asked Sep 05 '26 03:09

Doofus


1 Answers

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

like image 87
jmrk Avatar answered Sep 07 '26 17:09

jmrk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!