| Summary: | Intl.Locale maximize, minimize should return Intl.Locale instead of String | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | wopian | ||||||||||
| Component: | JavaScriptCore | Assignee: | Yusuke Suzuki <ysuzuki> | ||||||||||
| Status: | RESOLVED FIXED | ||||||||||||
| Severity: | Blocker | CC: | andy, ews-watchlist, keith_miller, mark.lam, mmaxfield, msaboff, ross.kirsling, saam, tzagallo, webkit-bug-importer, wopian, ysuzuki | ||||||||||
| Priority: | P2 | Keywords: | InRadar | ||||||||||
| Version: | Safari Technology Preview | ||||||||||||
| Hardware: | iPhone / iPad | ||||||||||||
| OS: | Other | ||||||||||||
| URL: | https://6f6bm.csb.app/ | ||||||||||||
| See Also: | https://bugs.webkit.org/show_bug.cgi?id=209772 | ||||||||||||
| Attachments: |
|
||||||||||||
|
Description
wopian
2020-07-11 10:40:10 PDT
Created attachment 404058 [details]
Output in iOS 14 Dev 2
Relevant sections of the specification: https://tc39.es/ecma402/#sec-Intl.Locale.prototype.maximize https://tc39.es/ecma402/#sec-Intl.Locale.prototype.minimize Created attachment 404078 [details]
Patch
Comment on attachment 404078 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=404078&action=review r=me, thanks! > Source/JavaScriptCore/runtime/IntlLocale.h:56 > - const String& maximize(); > - const String& minimize(); > + const String& maximal(); > + const String& minimal(); I'm not sure that we need to change the method names here just because we're changing the field names -- toString currently returns m_fullString, say. (Doesn't matter too much either way though since this is internal.) > Source/JavaScriptCore/runtime/IntlLocalePrototype.cpp:141 > + const String& fullString = locale->toString(); > + RELEASE_AND_RETURN(scope, JSValue::encode(fullString.isEmpty() ? jsUndefined() : jsNontrivialString(vm, fullString))); Hmm, my reasoning for not empty-checking these three is that we should have failed to construct an Intl.Locale at all if these can't be produced -- i.e. it would be ICU disagreeing *with itself* if these fail. > JSTests/ChangeLog:9 > + * stress/intl-locale-maximize-minimize.js: Added. I think we should just add to the relevant part of intl-locale.js, since this is a mistake in the basic behavior of these two methods. Comment on attachment 404078 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=404078&action=review >> Source/JavaScriptCore/runtime/IntlLocale.h:56 >> + const String& minimal(); > > I'm not sure that we need to change the method names here just because we're changing the field names -- toString currently returns m_fullString, say. > > (Doesn't matter too much either way though since this is internal.) I think this is better since IntlLocale#maximize() is confusing e.g. it looks like it is implementing Intl.Locale#maximize(). But this is not correct, and it is accessing maximal field of Intl.Locale. And Intl.Locale#maximize is doing the actual thing, which is wrapping Intl.Locale. >> Source/JavaScriptCore/runtime/IntlLocalePrototype.cpp:141 >> + RELEASE_AND_RETURN(scope, JSValue::encode(fullString.isEmpty() ? jsUndefined() : jsNontrivialString(vm, fullString))); > > Hmm, my reasoning for not empty-checking these three is that we should have failed to construct an Intl.Locale at all if these can't be produced -- i.e. it would be ICU disagreeing *with itself* if these fail. Discussed with Ross, I think using `jsString` in these Intl.Locale prototype functions is better since this is a boundary between third-party library (ICU) and JSC, and we are not guaranteeing our invariant in ICU. So being protective would be better. >> JSTests/ChangeLog:9 >> + * stress/intl-locale-maximize-minimize.js: Added. > > I think we should just add to the relevant part of intl-locale.js, since this is a mistake in the basic behavior of these two methods. Moved. Created attachment 404082 [details]
Patch for landing
Committed r264275: <https://trac.webkit.org/changeset/264275> All reviewed patches have been landed. Closing bug and clearing flags on attachment 404082 [details]. |