RESOLVED FIXED Bug 8993
Support function declaration in case statements
https://bugs.webkit.org/show_bug.cgi?id=8993
Summary Support function declaration in case statements
Anders Carlsson
Reported 2006-05-19 06:21:40 PDT
The spec doesn't support this, but all other browsers support it.
Attachments
layout test (1.09 KB, text/html)
2006-05-19 15:48 PDT, Geoffrey Garen
no flags
Patch with layout test and ChangeLog (5.94 KB, patch)
2006-05-19 16:49 PDT, Geoffrey Garen
no flags
Patch to prented that case statements are surrounded by curly braces (10.27 KB, patch)
2006-05-19 20:30 PDT, Geoffrey Garen
no flags
My implementation, for reference (2.89 KB, patch)
2006-05-20 01:15 PDT, Anders Carlsson
no flags
Actually include the code changes (15.85 KB, patch)
2006-05-20 01:19 PDT, Anders Carlsson
ggaren: review+
Geoffrey Garen
Comment 1 2006-05-19 15:47:31 PDT
Interestingly enough, WebKit supports this if the function case statement's body is enclosed in curly braces.
Geoffrey Garen
Comment 2 2006-05-19 15:48:35 PDT
Created attachment 8421 [details] layout test
Geoffrey Garen
Comment 3 2006-05-19 15:59:03 PDT
I'll take this one.
Geoffrey Garen
Comment 4 2006-05-19 16:49:02 PDT
Created attachment 8422 [details] Patch with layout test and ChangeLog
Geoffrey Garen
Comment 5 2006-05-19 20:30:12 PDT
Created attachment 8427 [details] Patch to prented that case statements are surrounded by curly braces I like this patch better because it follows my own advice and also removes cruft from the grammar. I still don't see why functions need to be distinguished in the grammar from plain old statements. Perhaps we can change that in another patch.
Darin Adler
Comment 6 2006-05-19 23:04:52 PDT
Comment on attachment 8427 [details] Patch to prented that case statements are surrounded by curly braces The grammar comes straight out of the ECMA standard. If there are things wrong with it, it probably means there are places where other browsers don't match the standard. The CaseClause and DefaultClause productions are on page 68 of ECMA-262 3rd edition.
Anders Carlsson
Comment 7 2006-05-20 01:15:11 PDT
Created attachment 8429 [details] My implementation, for reference I realize now that I had forgotten to upload my patch! Sorry about that, Geoff. It looks like we have different solutions to the problem. My patch always processes any function declarations wheras your patch does it before evaluating a case statement. I've tested with Opera, WinIE, MacIE and Firefox and everyone except Firefox follows the behavior I've implemented.
Anders Carlsson
Comment 8 2006-05-20 01:19:55 PDT
Created attachment 8430 [details] Actually include the code changes
Geoffrey Garen
Comment 9 2006-05-20 08:00:25 PDT
That's funny -- I tested only in Firefox :). The IE/Opera behavior seems strange to me, but for compatibility's sake, I think it's best. Anders, it looks like you uploaded only your layout test. Can you upload your patch as well?
Anders Carlsson
Comment 10 2006-05-20 08:47:35 PDT
Geoffrey Garen
Comment 11 2006-05-20 11:36:26 PDT
Comment on attachment 8430 [details] Actually include the code changes OK, I'm gonna r+ this one since it's the IE/Opera behavior.
Note You need to log in before you can comment on or make changes to this bug.