Bug 18735

Summary: SQUIRRELFISH: closures are sometimes given an incorrect 'this' value when called
Product: WebKit Reporter: Cameron Zwarich (cpst) <zwarich>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal    
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 18624    
Attachments:
Description Flags
Proposed patch
none
Revised proposed patch ggaren: review+

Description Cameron Zwarich (cpst) 2008-04-24 23:22:40 PDT
Consider the following example:

---

var text = "PASS";

function a()
{
  var text = "FAIL";
  function b()
  {
    alert(this.text);
  }

  this.c = function()
  {
    b();
  }
  b();
}

(new a()).c();

---

This code should print PASS twice, but instead prints PASS once and then FAIL. This affects the JavaScriptCore test js1_5/Scope/scope-003.js.
Comment 1 Cameron Zwarich (cpst) 2008-04-24 23:28:01 PDT
Created attachment 20812 [details]
Proposed patch

This patch fixes js1_5/Scope/scope-003.js, and it also fixes ecma/String/15.5.4.6-2.js.
Comment 2 Cameron Zwarich (cpst) 2008-04-24 23:32:06 PDT
Created attachment 20813 [details]
Revised proposed patch

The ecma/String/15.5.4.6-2.js fix doesn't seem legitimate, so I modified the ChangeLog to reflect this.
Comment 3 Cameron Zwarich (cpst) 2008-04-24 23:41:47 PDT
(In reply to comment #2)
> Created an attachment (id=20813) [edit]
> Revised proposed patch

SunSpider shows no change for this patch.
Comment 4 Geoffrey Garen 2008-04-24 23:45:36 PDT
Comment on attachment 20813 [details]
Revised proposed patch

r=me
Comment 5 Geoffrey Garen 2008-04-24 23:48:19 PDT
Committed revision 32536.

Comment 6 Cameron Zwarich (cpst) 2008-04-24 23:50:29 PDT
Upon further review, this patch really did legitimately fix that test case after all.