The spec doesn't support this, but all other browsers support it.
Interestingly enough, WebKit supports this if the function case statement's body is enclosed in curly braces.
Created attachment 8421 [details] layout test
I'll take this one.
Created attachment 8422 [details] Patch with layout test and ChangeLog
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.
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.
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.
Created attachment 8430 [details] Actually include the code changes
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?
I did that, it's in http://bugzilla.opendarwin.org/attachment.cgi?id=8430
Comment on attachment 8430 [details] Actually include the code changes OK, I'm gonna r+ this one since it's the IE/Opera behavior.