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

Ambiguous minimumFractionDigits resolution #946

Open
longlho opened this issue Dec 9, 2024 · 3 comments
Open

Ambiguous minimumFractionDigits resolution #946

longlho opened this issue Dec 9, 2024 · 3 comments

Comments

@longlho
Copy link
Collaborator

longlho commented Dec 9, 2024

In https://tc39.es/ecma402/#sec-setnfdigitoptions 23.a.iii the sequence to set mnfd is ambiguous when mxfd is undefined.

3. Let mxfd be ? Get(options, "maximumFractionDigits").
...
ii. Set mxfd to ? DefaultNumberOption(mxfd, 0, 100, undefined).
iii. If mnfd is undefined, set mnfd to min(mnfdDefault, mxfd).

At this point, mxfd can be undefined which makes the operation min(mnfdDefault, mxfd) ambiguous. How should I handle this case?

Ref: formatjs/formatjs#4678

@anba
Copy link
Contributor

anba commented Dec 9, 2024

If mnfd is undefined, then mxfd is guaranteed to be non-undefined, because if both are undefined, then hasFd is set to false and step 23 isn't entered.

@longlho
Copy link
Collaborator Author

longlho commented Dec 9, 2024

Ah yeah you're right. Would it hurt to assert at that step?

@sffc
Copy link
Contributor

sffc commented Dec 9, 2024

Right; hasFd means that either mnfd or mxfd is not undefined, so mnfd is undefined implies mxfd is not undefined and vice versa.

I'd be open to a comment or an assertion. If an assertion is used, we should add assertions throughout SetNumberFormatDigitOptions. I think I lean toward a comment in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants