[Webkit-unassigned] [Bug 65546] New: function statements are evaluated even if enclosed in a not-executed code block (see #27226)

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Aug 2 09:47:06 PDT 2011


           Summary: function statements are evaluated even if enclosed in
                    a not-executed code block (see #27226)
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: All
        OS/Version: All
            Status: UNCONFIRMED
          Severity: Major
          Priority: P2
         Component: JavaScriptCore
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: eeelnico at gmail.com

Created an attachment (id=102660)
 --> (https://bugs.webkit.org/attachment.cgi?id=102660&action=review)
a simple test case to show how this bug can affect a real application.

this may seem strange, and with not severe consequences, but if you take a look at the supplied test case, you'll see how this can cause runtime errors.
(that are not easy to debug or detect)

Explanation of the attachments:
If you have a js-class, defined by a function statement that uses the "this" keyword in its body, like this:
function A(){ this.name = "A"; }

and you add behaviour to its prototype:
A.prototype.foo = function(){ ... }

and later you add a JS file to your document, with the above code surrounded by an if(condition) with a false-condition,
then the function statement is evaluated AGAIN, and then the A Object is set back to its initial state (without .foo), 
causing a runtime error when you try to:
( new A() ).foo();

Carol Szabo's description in #27226 (from 2009-07-13) is very important, 
and I agree that the desired (and intuitive) behavior is the one in section 13, as Firefox does.

It's also interesting what Daniel Parks says, as this bug does not happen if you code like this:
var A = function(){ this.name = "A"; }
but we know most js developers define js-classes the other way.

(NOTE: in http://www.webkit.org/quality/bugwriting.html it said there would be a "Depends on" field, but I could not find it, sorry).

Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

More information about the webkit-unassigned mailing list