Bug 157041 - The error message for for-of loops without Symbol.iterator is awful.
Summary: The error message for for-of loops without Symbol.iterator is awful.
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Saam Barati
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-26 13:44 PDT by Keith Miller
Modified: 2016-10-18 02:40 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Keith Miller 2016-04-26 13:44:03 PDT
The error message is possibly one of the worst I have ever seen...

>>> for (a of {}) {}
Exception: TypeError: a of {} is not a function. (In 'a of {}', 'a of {}' is undefined)

I'm not even remotely sure how anyone would be able to debug this without tears.
Comment 1 Joseph Pecoraro 2016-05-10 15:12:38 PDT
This goes even more bonkers if the left hand side is a variable declaration with destructuring, it seems to include source text outside of the for loop entirely:

>>> /* comment */ for (var {a} of {}) {}
Exception: TypeError: /* comment */ for (var {a} of {} is not a function. (In '/* comment */ for (var {a} of {}', '/* comment */ for (var {a} of {}' is undefined)
Comment 2 Joseph Pecoraro 2016-10-13 20:27:07 PDT
Heh, this makes me chuckle every time I see it!
Comment 3 Saam Barati 2016-10-18 02:40:59 PDT
Hah I'll try to fix this tmrw.