Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[FEEDBACK] Limits of Digit Size Options #960

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

Closed
sffc opened this issue Nov 25, 2024 · 5 comments · Fixed by #1070
Closed

[FEEDBACK] Limits of Digit Size Options #960

sffc opened this issue Nov 25, 2024 · 5 comments · Fixed by #1070
Labels
functions Issue pertains to the default function set Preview-Feedback Feedback gathered during the technical preview

Comments

@sffc
Copy link
Member

sffc commented Nov 25, 2024

The Digit Size Options in registry.md say they use the following EBNF:

digit-size-option = "0" / (("1"-"9") [DIGIT])

This appears to accept 0, 1, 2, ..., 9, 10, 11, ..., 98, 99.

However, ECMA-402 restricts the range of some of these integers to be less. For example, minimum and maximum significant digits and minimum integer digits are restricted to the range 1-21:

https://tc39.es/ecma402/#sec-setnfdigitoptions

@sffc sffc added the Preview-Feedback Feedback gathered during the technical preview label Nov 25, 2024
@eemeli
Copy link
Collaborator

eemeli commented Nov 25, 2024

Given that the spec also includes

A "digit size option" is an _option_ value that the _function_ interprets
as a small integer value greater than or equal to zero.
Implementations MAY define an upper limit on the _resolved value_
of a digit size option option consistent with that implementation's practical limits.

it's not clear to me what this feedback is about?

@sffc
Copy link
Member Author

sffc commented Nov 25, 2024

I feel limits on these options should be more strict in general because it is a dereliction of duty for MF2 to allow a message that is supported in one implementation but rejected in another (without using implementation-specific namespaced options), but I'll leave it up to the WG to decide if this text, permitting engines to differ in the limits they impose, is acceptable to MF2.

@aphillips aphillips added the functions Issue pertains to the default function set label Mar 8, 2025
@aphillips
Copy link
Member

@sffc What change would you propose here? The goal would be to restrict the upper size of a digit size option's value without restricting numeric types supported by implementations. Note that we have limited the size to 99, while BigDecimal/BigInteger types existing in various languages that can exceed this (the practicality, of course, of formatting that many digits might be questioned).

Note that the ABNF is a syntactic limit. We would probably change that syntax if we agree on a practical upper limit < 99.

it is a dereliction of duty for MF2 to allow a message that is supported in one implementation but rejected in another (without using implementation-specific namespaced options)

This would not happen because the message will not be rejected. Exceeding 99 or an implementation-defined limit can only result in a Bad Option error. These are never fatal (i.e. message-rejecting):

The result of option resolution MUST be a (possibly empty) mapping of string identifiers to values; that is, errors MAY be emitted, but such errors MUST NOT be fatal.

@aphillips aphillips added the resolve-candidate This issue appears to have been answered or resolved, and may be closed soon. label Apr 14, 2025
@sffc
Copy link
Member Author

sffc commented Apr 14, 2025

@aphillips explained to me that what this means is:

  • Error handling for this option is to emit a non-fatal error and drop the option
  • All implementations must error if the value exceeds 99
  • ECMAScript could error if the value exceeds 21

Since the error is non-fatal, you get GIGO-like behavior, so nothing actually breaks; you don't get data-driven exceptions, which is what I'm concerned about.

@aphillips
Copy link
Member

2024-04-14 call: Need to allow clamping.

@aphillips aphillips added PR-needed Issue is blocked on having a PR created and removed resolve-candidate This issue appears to have been answered or resolved, and may be closed soon. labels Apr 14, 2025
aphillips added a commit that referenced this issue Apr 14, 2025
Fixes #960 

Per the discussion in the 2025-04-14 telecon, allow digit size options to be to clamped to an implementation-specific value.
@aphillips aphillips removed the PR-needed Issue is blocked on having a PR created label Apr 14, 2025
aphillips added a commit that referenced this issue May 12, 2025
* Allow clamping of digit size options

Fixes #960 

Per the discussion in the 2025-04-14 telecon, allow digit size options to be to clamped to an implementation-specific value.

* Update spec/functions/number.md

Co-authored-by: Eemeli Aro <[email protected]>

* Address comments

* Make clear ignorance and clamping behavior

* Address Tim's action item

---------

Co-authored-by: Eemeli Aro <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
functions Issue pertains to the default function set Preview-Feedback Feedback gathered during the technical preview
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants