Bug 21362 - "this" object in methods called on primitives should be wrapper object
Summary: "this" object in methods called on primitives should be wrapper object
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-03 23:58 PDT by Maciej Stachowiak
Modified: 2008-10-04 08:58 PDT (History)
0 users

See Also:


Attachments
the fix, with test case (23.10 KB, patch)
2008-10-04 00:02 PDT, Maciej Stachowiak
zwarich: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Maciej Stachowiak 2008-10-03 23:58:09 PDT
In cases like this:

String.prototype.thisType = function() { return typeof this; };
Number.prototype.thisType = function() { return typeof this; };
Boolean.prototype.thisType = function() { return typeof this; };

shouldBe("(1).thisType()", "'object'");
shouldBe("(2.3).thisType()", "'object'");
shouldBe("'xxx'.thisType()", "'object'");
shouldBe("(false).thisType()", "'object'");

We're currently providing the raw number or string or bool as the "this" value, which is subtly wrong.
Comment 1 Maciej Stachowiak 2008-10-04 00:02:11 PDT
Created attachment 24084 [details]
the fix, with test case
Comment 2 Cameron Zwarich (cpst) 2008-10-04 00:12:16 PDT
Comment on attachment 24084 [details]
the fix, with test case

r=me
Comment 3 Cameron Zwarich (cpst) 2008-10-04 08:58:32 PDT
Landed in r37285.