Closed Bug 1175173 Opened 6 years ago Closed 6 years ago

Don't box primitives in {Object, Array}.prototype.toLocaleString

Categories

(Core :: JavaScript: Standard Library, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla43
Tracking Status
firefox41 --- affected
firefox43 --- fixed

People

(Reporter: anba, Assigned: evilpie)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

js> String.prototype.toString = function(){"use strict"; return typeof this;}
(function (){"use strict"; return typeof this;})
js> Object.prototype.toLocaleString.call("")
"object"
js> [""].toLocaleString()
"object"

Expected: Both toLocaleString() calls return "string"
Actual: "object" is returned

Also see: https://bugs.ecmascript.org/show_bug.cgi?id=3237
Assignee: nobody → evilpies
Attached patch fixSplinter Review
Attachment #8646277 - Flags: review?(till)
Comment on attachment 8646277 [details] [diff] [review]
fix

Review of attachment 8646277 [details] [diff] [review]:
-----------------------------------------------------------------

Nice. r=me with nits addressed.

::: js/src/builtin/Object.js
@@ +50,5 @@
>  function ObjectIsExtensible(obj) {
>      return IsObject(obj) && std_Reflect_isExtensible(obj);
>  }
>  
> +function Object_toLocaleString() {

Nit: add comment along the lines of "// ES2015 19.1.3.5 Object.prototype.toLocaleString."

@@ +56,5 @@
> +    var O = this;
> +
> +    // Step 2.
> +    var func = O.toString;
> +    return callFunction(func, O);

Hmm, does it make any difference to split this into two steps? Doesn't `O.toString()` behave exactly the same?
Attachment #8646277 - Flags: review?(till) → review+
https://hg.mozilla.org/mozilla-central/rev/47e0a4c1d109
Status: NEW → RESOLVED
Closed: 6 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla43
You need to log in before you can comment on or make changes to this bug.