Bug 15985 - function declaration inside a statement behaves differently from Firefox, but the same as IE
Summary: function declaration inside a statement behaves differently from Firefox, but...
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.4
: P2 Normal
Assignee: Nobody
URL: http://trac.webkit.org/projects/webki...
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-14 08:09 PST by Feng Qian
Modified: 2007-11-19 14:57 PST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Feng Qian 2007-11-14 08:09:58 PST
In the layout test, fast/js/function-declarations-in-switch-statement.html. Function declarations in a switch statement. SpiderMonkey assigns function body to function name dynamically (only initializes the function name when the statement is executed). KJS and IE initialize the function name with the last declaration no matter the statement is executed or not.

Function declaration in a statement is not part of ECMA-262. The real question is which behavior should KJS have, IE or Firefox?
Comment 1 Eric Seidel (no email) 2007-11-19 14:54:02 PST
Generally we work hard to be compatible both, but when we have to choose: IE over firefox.  The reason is generally simple market share advantage.  If 80% of the web is surfing with IE, it's more likely that pages will be written to be compatible with IE than firefox.

Now, I'm not certain that in this specific issue it's "correct" to follow one or the other.  But if we ever were aware of this choice, we probably chose to follow IE's behavior.
Comment 2 Mark Rowe (bdash) 2007-11-19 14:55:14 PST
See http://bugs.webkit.org/show_bug.cgi?id=8993#c9.  Without a specific real-world case for changing this, matching IE and Opera seems like the best approach for compatibility.
Comment 3 Eric Seidel (no email) 2007-11-19 14:57:22 PST
It looks like we very intentionally try to match IE's behavior here, based on the layout test you mention:

http://trac.webkit.org/projects/webkit/browser/trunk/LayoutTests/fast/js/resources/function-declarations-in-switch-statement.js

I would argue that firefox diverging from the "common behavior" is a bug on their side.