ecma402
ecma402 copied to clipboard
Ambiguous minimumFractionDigits resolution
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: https://github.com/formatjs/formatjs/issues/4678
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.
Ah yeah you're right. Would it hurt to assert at that step?
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.