Bug 157041

Summary: The error message for for-of loops without Symbol.iterator is awful.
Product: WebKit Reporter: Keith Miller <keith_miller>
Component: JavaScriptCoreAssignee: Fady Farag <com.webkit.iidmsa>
Status: RESOLVED FIXED    
Severity: Normal CC: com.webkit.iidmsa, joepeck, saam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Keith Miller
Reported 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.
Attachments
Joseph Pecoraro
Comment 1 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)
Joseph Pecoraro
Comment 2 2016-10-13 20:27:07 PDT
Heh, this makes me chuckle every time I see it!
Saam Barati
Comment 3 2016-10-18 02:40:59 PDT
Hah I'll try to fix this tmrw.
Radar WebKit Bug Importer
Comment 4 2025-09-03 20:13:38 PDT
Fady Farag
Comment 5 2025-09-03 20:26:25 PDT
EWS
Comment 6 2025-09-18 06:18:12 PDT
Committed 300154@main (0051bbf2491f): <https://commits.webkit.org/300154@main> Reviewed commits have been landed. Closing PR #50282 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.