New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array.toLocaleString should return typeof string instead string value #5621

Closed
soterojunior opened this Issue Aug 22, 2018 · 8 comments

Comments

Projects
None yet
6 participants
@soterojunior
Copy link

soterojunior commented Aug 22, 2018

Hi everyone,

I find out an inconsistency in Array.toLocaleString when typeof this is called the return is test. V8, SpiderMonkey and JavaScriptCore return string as expected.

Chakra version: 1.10.2.0
O.S: MacOS High Sierra version 10.13.6

step to reproduce:

"use strict";

Object.defineProperty(String.prototype, "toLocaleString", {
    get() {
        return function() { return typeof this; };
    }
})

print(["test"].toLocaleString())

actual result:
test

expected result:
string

cinfuzz

@kfarnung

This comment has been minimized.

Copy link
Member

kfarnung commented Aug 22, 2018

ESHost repro:

> eshost -is test5.js
## Source
"use strict";

Object.defineProperty(String.prototype, "toLocaleString", {
    get() {
        return function() { return typeof this; };
    }
})

print(["test"].toLocaleString())

#### cc-1.7.6, cc-1.8.5, Chakra
test

#### JavaScriptCore, SpiderMonkey, V8, V8 --harmony
string

@kfarnung kfarnung added this to the vNext milestone Aug 22, 2018

@kfarnung

This comment has been minimized.

Copy link
Member

kfarnung commented Aug 22, 2018

@jackhorton

This comment has been minimized.

Copy link
Member

jackhorton commented Aug 22, 2018

Array.prototype.toLocaleString already needs to be updated to Intl spec, which explicitly calls out that toLocaleString should be invoked on each element. The current fix is only one line, though, so ill probably throw it in with my current Intl PR

@jackhorton

This comment has been minimized.

Copy link
Member

jackhorton commented Aug 28, 2018

Since its a simple fix, I am going to label this as a good first issue instead.

@Fly-Style

This comment has been minimized.

Copy link

Fly-Style commented Sep 14, 2018

Can I pick it?

@rhuanjl

This comment has been minimized.

Copy link
Contributor

rhuanjl commented Sep 14, 2018

@Fly-Style from one external contributor to another - if an issue is marked help wanted, has no referenced PR and no one else has commented saying they're doing it just give it a try (and comment saying that you are) no reason to wait for someone to say you can - the help wanted label already tells you that.

@jackhorton

This comment has been minimized.

Copy link
Member

jackhorton commented Sep 14, 2018

Go for it! To start, I would look at the method Js::JavascriptArray::EntryToLocaleString, and follow along from there to the point where the conversion actually takes place.

@mintunitish

This comment has been minimized.

Copy link

mintunitish commented Sep 28, 2018

I will be taking this. Any pointers on where to start?

@chakrabot chakrabot closed this in 4764a5f Oct 5, 2018

chakrabot added a commit to nodejs/node-chakracore that referenced this issue Oct 6, 2018

deps: update ChakraCore to Microsoft/ChakraCore@4764a5f
[MERGE #5742 @Dachande663] Fixed #5621 - toLocaleString now accesses object property

Merge pull request #5742 from Dachande663:pr/dachande663/fix-tolocalestring-object-property

As per issue Microsoft/ChakraCore#5621, this PR enables toLocaleString to call JavascriptString underlying property.

Reviewed-By: chakrabot <chakrabot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment