Skip to content

Implement Intl.PluralRules - #4940

Merged
chakrabot merged 3 commits into
chakra-core:masterfrom
jackhorton:intl/plural-rules
May 8, 2018
Merged

Implement Intl.PluralRules#4940
chakrabot merged 3 commits into
chakra-core:masterfrom
jackhorton:intl/plural-rules

Conversation

@jackhorton

@jackhorton jackhorton commented Apr 5, 2018

Copy link
Copy Markdown
Contributor

After looking into Intl.PluralRules last night, I realized it was really simple and straightforward to implement. This brings us to full Intl API support except for Intl.NumberFormat.prototype.formatToParts().

Fixes #4799

* @param {Object} options
* @param {Number} mnfdDefault
* @param {Number} mxfdDefault
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

descriptions for these params might help because I don't know immediately what mxfd means

return platform.pluralRulesSelect(pluralRules, n);
};

const PluralRules = function (locales = undefined, options = undefined) {

@sethbrenith sethbrenith Apr 5, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= undefined [](start = 45, length = 12)

unsupplied params are undefined by default, we don't need to specify it #ByDesign

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, but test262 is exceptionally finicky about lengths of functions. This allows us to have formal parameters but keep the length as 0, and is done for other functions throughout the file too.

@dilijev dilijev Apr 9, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This raises the point that this is a by-design "anti-pattern" that many may think is unnecessary when reading and updating the code, and probably warrants a comment per-occurrence explaining why. (to wit: "// use = undefined on formals to force the length of the function to be 0, per spec")

@sethbrenith sethbrenith left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@jackhorton
jackhorton force-pushed the intl/plural-rules branch 2 times, most recently from f34bdde to 1c21307 Compare April 26, 2018 21:52

return JavascriptString::NewWithBuffer(selected, static_cast<charcount_t>(selectedLength), scriptContext);
#else
AssertOrFailFastMsg(false, "Intl-WinGlob should not be using PluralRuleKeywords");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PluralRuleKeywords [](start = 69, length = 18)

nit: PluralRulesSelect (?)

@dilijev dilijev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@dilijev

dilijev commented May 2, 2018

Copy link
Copy Markdown
Contributor

Overall LGTM. The pre-61 "hack" seems a little questionable. What versions can it work under? (What is the minimum ICU version we support? Are there source code guards for that? Is the hack truly safe? In any case, 61 is (I think?) the main target so it's not a super huge problem.

@jackhorton

Copy link
Copy Markdown
Contributor Author

The hack does suck but I don't know of a better way to handle it aside from dragging every flavor of chakra/core to 61 all at once, kicking and screaming. For some value of "official support," we officially support back to ICU 55, since that's system ICU on Ubuntu 16.04

@dilijev

dilijev commented May 2, 2018

Copy link
Copy Markdown
Contributor

@jackhorton since we make assumptions based on minimum version of ICU 55, should we intentionally break the build if we detect an earlier ICU?

@jackhorton

Copy link
Copy Markdown
Contributor Author

The worst thing that can happen is an API that we need not being there, which should be caught at launch (I have seen it happen on Windows at least). I am not aware of critical behavioral differences between versions of the API.

@jackhorton jackhorton changed the title WIP: Implement Intl.PluralRules Implement Intl.PluralRules May 2, 2018
@jackhorton
jackhorton force-pushed the intl/plural-rules branch 2 times, most recently from d604f1d to 54fc55f Compare May 3, 2018 18:49
@dilijev

dilijev commented May 3, 2018

Copy link
Copy Markdown
Contributor

Any major changes since the last iteration you'd like a set of eyes on?

@jackhorton

Copy link
Copy Markdown
Contributor Author

Nope, I mainly updated to fix tc39/ecma402#224. I am re-baselining chakrafull right now before merging this.

@jackhorton
jackhorton force-pushed the intl/plural-rules branch 3 times, most recently from 59c0f5a to 0c9a60f Compare May 7, 2018 21:49
@jackhorton
jackhorton force-pushed the intl/plural-rules branch from 0c9a60f to 56df095 Compare May 8, 2018 15:41
@chakrabot
chakrabot merged commit 56df095 into chakra-core:master May 8, 2018
chakrabot pushed a commit that referenced this pull request May 8, 2018
Merge pull request #4940 from jackhorton:intl/plural-rules

Fixes #4799
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants