-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Intl.[ctor] called with unusual target produces strange behavior #3692
Comments
@bterlson I'm sure that our behavior here is simply incorrect, but I want to make sure we get all the nuances of the behavior in the fix for this. I'm having a hard time reading through the relevant spec to see what all the cases would be. https://tc39.github.io/ecma402/#sec-intl-numberformat-constructor |
@dilijev what cases are you referring to? How can I help? |
@bterlson basically the Intl.js code in this case doesn't read very much like the spec. Might need a 1:1 with you to go over terminology and walk through the code. This can wait since it's Backlog for now. It might not be relevant here but I get kind of lost when I start seeing ReturnIfAbrupt notations. Having difficulty with this line;
That almost makes it sound like what we do in this case is some semblance of correct (maybe a little off) and that the other engines are wrong too, but I feel like that can't be right because the behavior makes no sense. |
I have wondered about our behavior here too... I am almost sure its wrong, but its not entirely clear how to be right from reading the spec. |
…t262 issues, add support for ICU 62.1 Merge pull request #5612 from jackhorton:intl/lots-of-fixes Fixes #637 Fixes #5603 Fixes #3427 Fixes #3513 Fixes #3692 Adds build support for ICU 62.1 by enabling /utf-8 in all ICU files rather than just i18n @rhuanjl's function.length PR took our pass rate from 486 to 530; this further increases it to 580 (compared to V8's 582 and SpiderMonkey's 597). The remaining failures are all known, but slightly more complicated issues, where we shell out to ICU when the spec wants us to do something particularly snowflake-y -- V8 fails most of these tests as well. The remaining ~350 tests are for features that we don't implement and V8/SM either haven't implemented or have turned off by default. For what its worth, some of the features we haven't implemented are extremely straightforward -- the Intl version of String.prototype.toLocale{Lower|Upper}Case and {Typed}Array.prototype.toLocaleString are tiny. Fixing those tests (by implementing those features) would bump us up to 596.
Found by reading code and wondering "what does this button do?"
Apparently Intl.* constructors do not actually have to be called with new, and can be called with anything as the target.
Using
Intl
orundefined
as the target (first param ofcall
) produces the same result as calling new.Specifically allowing the target to be
Intl
orundefined
(see Intl.js code, snippet below) allows for calling asIntl.NumberFormat
and assigning the same to a var and then calling, producing the same results.Using anything else apparently returns the object passed in:
Which leads to fun things like formatting a Date with something you would have hoped was a NumberFormat object
The text was updated successfully, but these errors were encountered: