chakra-core / ChakraCore

ChakraCore is an open source Javascript engine with a C API.
MIT License
9.12k stars 1.2k forks source link

Wrong realization of TypedArray's toLocaleString() #5653

Open sunlili opened 6 years ago

sunlili commented 6 years ago

Executing following code in ch 1.10 :

Uint8Array.prototype.toLocaleString.call(0)

The output is "" However, in specific : "ValidateTypedArray is applied to the this value prior to evaluating the algorithm. " So, a TypeError should be thrown.

BT group 2018.08.29

fatcerberus commented 6 years ago

Interestingly there's a spec note here that if the ECMA-402 Intl API is present (which CC does implement) then the algorithm should instead be based on that of Array.prototype.toLocaleString - does that then invalidate the requirement to invoke ValidateTypedArray, I wonder? Intuitively one would expect that caveat to still apply but specifications can be fickle things.

zenparsing commented 6 years ago

@fatcerberus It is a bit oddly worded, but in this case ValidateTypedArray must still be applied to the typed array, since the algorithm will need to access internal slots instead of a "length" property, and will need to make sure that the typed array has not been detached.

fatcerberus commented 6 years ago

Alright, thanks - that’s what I intuitively expected but you can never be too sure with cases like this. :)