Bug 169182 - Currency digits calculation in Intl.NumberFormat should call out to ICU
Summary: Currency digits calculation in Intl.NumberFormat should call out to ICU
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Minor
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-05 09:47 PST by Daniel Ehrenberg
Modified: 2017-03-15 16:40 PDT (History)
6 users (show)

See Also:


Attachments
Patch (3.49 KB, patch)
2017-03-05 09:56 PST, Daniel Ehrenberg
no flags Details | Formatted Diff | Diff
Patch (3.64 KB, patch)
2017-03-06 01:47 PST, Daniel Ehrenberg
no flags Details | Formatted Diff | Diff
Patch (3.83 KB, patch)
2017-03-13 08:58 PDT, Daniel Ehrenberg
no flags Details | Formatted Diff | Diff
Patch (4.00 KB, patch)
2017-03-13 10:28 PDT, Daniel Ehrenberg
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Ehrenberg 2017-03-05 09:47:43 PST
Intl.NumberFormat currently uses a fixed list of currencies which have a number of decimal digits different from 2. I wrote a patch to call out to ICU's function ucurr_getDefaultFractionDigits instead and will shortly upload it as an alternate solution. This is less code and may give an updated list of currencies in the future when ICU updates.
Comment 1 Daniel Ehrenberg 2017-03-05 09:56:39 PST
Created attachment 303458 [details]
Patch
Comment 2 Daniel Ehrenberg 2017-03-06 01:47:20 PST
Created attachment 303505 [details]
Patch
Comment 3 Yusuke Suzuki 2017-03-06 02:00:58 PST
Comment on attachment 303505 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=303505&action=review

r=me

> Source/JavaScriptCore/ChangeLog:11
> +        (JSC::extractCurrencySortKey): Deleted.

If it involves some behavior change, can you add a test for that? (in JSTests/stress/)
Comment 4 Daniel Ehrenberg 2017-03-06 03:54:33 PST
This patch does not involve any behavior change.
Comment 5 Yusuke Suzuki 2017-03-06 05:38:39 PST
Comment on attachment 303505 [details]
Patch

OK. I've just set cq+. This patch will be landed through the commit queue.
You can set cq=? in addition to r=? to request reviewers / committers to post to cq when r+ is set :)
Comment 6 WebKit Commit Bot 2017-03-06 06:06:21 PST
Comment on attachment 303505 [details]
Patch

Clearing flags on attachment: 303505

Committed r213447: <http://trac.webkit.org/changeset/213447>
Comment 7 WebKit Commit Bot 2017-03-06 06:06:25 PST
All reviewed patches have been landed.  Closing bug.
Comment 8 Daniel Ehrenberg 2017-03-10 09:57:47 PST
Sorry, it turns out I was wrong when I thought this patch didn't change observable behavior. It actually introduces a spec violation, though it matches V8 behavior, and I suspect the right fix is to change the spec eventually. Details are in https://github.com/tc39/ecma402/issues/134 .

Either way, in the short term, maybe this patch should be reverted. Is there a particular procedure for making a revert, or should I just upload another patch that reverts this one?
Comment 9 Darin Adler 2017-03-12 20:10:28 PDT
If you haven’t already, please just upload another patch that reverts this one.
Comment 10 Darin Adler 2017-03-12 20:12:04 PDT
It’s often a mistake to use a library directly in WebKit; often the people changing those libraries don’t consider the effect on web technology when they change them. Because of this we often need a white list or other mechanism between WebKit and the underlying library.

(In fact, we likely need to do this for character encodings and ICU if we haven’t done it already.)
Comment 11 Daniel Ehrenberg 2017-03-13 07:13:13 PDT
In this case, the reason why it's a mistake is very subtle. The library gives linguistically more accurate information than what WebKit uses otherwise. Updates to the library should be for the same goal as providing linguistically accurate information. WebKit makes heavy use of ICU in other places. Chromium has long called out to ICU for this information, and three major browsers use ICU for other parts of Intl.NumberFormat generally. Do you think that WebKit would benefit from reimplementing icu::DecimalFormat to reduce dependency on ICU in its ECMA 402 implementation?

Here, use of the library is disallowed because the specification of JavaScript requires a particular information source with more legalistic and less linguistically relevant data. I'm pursuing a change in the specification at  https://github.com/tc39/ecma402/issues/134 because I think it will give users better behavior.

Anyway, sorry for the churn here! I'll upload a revert patch soon.
Comment 12 Daniel Ehrenberg 2017-03-13 08:58:21 PDT
Reopening to attach new patch.
Comment 13 Daniel Ehrenberg 2017-03-13 08:58:27 PDT
Created attachment 304259 [details]
Patch
Comment 14 Saam Barati 2017-03-13 09:27:57 PDT
Comment on attachment 304259 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=304259&action=review

> Source/JavaScriptCore/ChangeLog:3
> +        Revert patch to call out to ICU for CurrencyDigits

Nit: please say which revision you're rolling out.

> Source/JavaScriptCore/ChangeLog:5
> +        The previous patch was currently technical invalid because ECMA 402

Style nit: we usually put this after the "reviewed by" line. 
Also, "currently techinical invalid" => "is technically invalid"?
Comment 15 Daniel Ehrenberg 2017-03-13 10:28:03 PDT
Created attachment 304272 [details]
Patch
Comment 16 Daniel Ehrenberg 2017-03-13 10:28:40 PDT
Thanks for the quick reviews. I fixed up the commit message in a new version of the patch.
Comment 17 WebKit Commit Bot 2017-03-15 16:40:28 PDT
Comment on attachment 304272 [details]
Patch

Clearing flags on attachment: 304272

Committed r214020: <http://trac.webkit.org/changeset/214020>
Comment 18 WebKit Commit Bot 2017-03-15 16:40:33 PDT
All reviewed patches have been landed.  Closing bug.