Closed
Bug 41864
Opened 24 years ago
Closed 24 years ago
ECMA function call incompatibility
Categories
(Core :: JavaScript Engine, defect, P1)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
M17
People
(Reporter: waldemar, Assigned: brendan)
Details
(Keywords: js1.5)
Attachments
(1 file)
6.47 KB,
patch
|
Details | Diff | Splinter Review |
name='win'; obj1={name:'obj1'}; obj1.f=function(){alert(this.name)} obj2={name:'obj2'}; (obj2.f=obj1.f)(); (replace 'alert' with 'print' in JSRef). The code above should print 'win'. It prints 'obj2'. Another test case is: (obj2.f,obj1.f)(); This should also print 'win'. It prints 'obj1'. The reason is as follows: Step 3 of ECMA 11.13.1 calls GetValue, which turns a reference to a regular value. That value is then returned in step 5. A function call (section 11.2.3) looks to see if the function is a reference or a regular value. If it's a reference then it extracts its base and assigns it to the "this" variable. If it's a regular value, then the "this" variable becomes null (step 6 of 11.2.3). The [[call]] method then changes "this" to point to the global object (the last paragraph of 10.2.3). That's why this.name should be 'win'.
Assignee | ||
Comment 1•24 years ago
|
||
Adding js1.5. Patch coming up. /be
Assignee: rogerl → brendan
Keywords: js1.5
Assignee | ||
Comment 2•24 years ago
|
||
Adding more JS1.5 buddies. /be
Status: NEW → ASSIGNED
Target Milestone: --- → M17
Assignee | ||
Comment 3•24 years ago
|
||
Assignee | ||
Updated•24 years ago
|
Priority: P3 → P1
Assignee | ||
Comment 4•24 years ago
|
||
Fix checked in. Thanks pschwartau for the thumbs-up regression testing. /be
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Hardware: Macintosh → All
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•