Skip to content
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

ApplyUnicodeExtensionToTag and ResolveLocale set the result record's internal slots to non-canonical values #707

Closed
trflynn89 opened this issue Aug 29, 2022 · 3 comments · Fixed by #846
Assignees
Labels
bug c: locale Component: locale identifiers s: discuss Status: TG2 must discuss to move forward
Milestone

Comments

@trflynn89
Copy link
Contributor

trflynn89 commented Aug 29, 2022

In ApplyUnicodeExtensionToTag and ResolveLocale, we loop over the provided relevant extension keys, and set the corresponding internal slot of the result record to the value present in either the locale string or options object:

6. For each element key of relevantExtensionKeys, do
    ...
    g. Set result.[[<key>]] to value.

This happens before the values are canonicalized via InsertUnicodeExtensionAndCanonicalize:

9. If newExtension is not the empty String, then
    a. Let locale be ! InsertUnicodeExtensionAndCanonicalize(locale, newExtension)    .
10. Set result.[[locale]] to locale.
11. Return result.

Thus, the locale string of the corresponding Intl object is canonicalized, but the extension key internal slots are non-canonical.

The formatjs polyfill shows this issue:

import '@formatjs/intl-locale/polyfill.js'

const loc = new Intl.Locale('en', {calendar: 'islamicc'});
console.log(loc.toString());
console.log(loc.calendar);

That prints:

en-u-ca-islamic-civil
islamicc

test262 expects loc.calendar to be canonicalized (and that is how v8 and spidermonkey already behave).

@sffc sffc added bug c: locale Component: locale identifiers s: help wanted Status: help wanted; needs proposal champion labels Dec 14, 2023
@sffc sffc added this to the ES 2024 milestone Dec 14, 2023
@sffc sffc added s: discuss Status: TG2 must discuss to move forward and removed s: help wanted Status: help wanted; needs proposal champion labels Dec 14, 2023
@FrankYFTang FrankYFTang self-assigned this Dec 14, 2023
@FrankYFTang
Copy link
Contributor

We discuss this in TG2 Dec 14 2023 and think it is truely an issue. Frank will take action to produce a Normative PR around step 5.f / 5.g of ApplyUnicodeExtensionToTag which similar to what ResolveLocale did in

step 9.i.iii.3 "3. Set optionsValue to the String value resulting from canonicalizing optionsUValue as a value of key ukey per Unicode Technical Standard #35 Part 1 Core, Annex C LocaleId Canonicalization Section 5 Canonicalizing Syntax, Processing LocaleIds."

@FrankYFTang
@gibson042 said he will review that PR

@FrankYFTang
Copy link
Contributor

Proposed fix in #846

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug c: locale Component: locale identifiers s: discuss Status: TG2 must discuss to move forward
Projects
Status: Previously Discussed
Development

Successfully merging a pull request may close this issue.

4 participants