[Webkit-unassigned] [Bug 33763] New: Defining functions with "if(true) else" clause, results in the last function to be defined.

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Jan 16 11:12:50 PST 2010


https://bugs.webkit.org/show_bug.cgi?id=33763

           Summary: Defining functions with "if(true) else" clause,
                    results in the last function to be defined.
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: PC
        OS/Version: Windows Vista
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: JavaScriptCore
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: bgerrissen at gmail.com


Try:

if(true) {
   function test() {
      alert("SUCCESS!");
   }
} else {
   function test() {
      alert("FAIL!");
   }
}

test(); // alerts "FAIL!"

Not sure if I listed the correct webkit version, this bug happens for me in
Windows Safari 4.0.4 (531.21.10)
I suspect all function declarations are evaluated ignoring the if/else clause.

Bug mitigation, declare functions as variables...

if(true) {
   var test = function() {
      alert("SUCCESS!");
   }
} else {
   var test = function() {
      alert("FAIL!");
   }
}

test(); // alerts "SUCCESS!"

-- 
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