Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 23 additions & 28 deletions spec/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,8 @@ where `resolvedSelector` is the _resolved value_ of a _selector_
and `keys` is a list of strings,
numeric selectors perform as described below.

1. Let `exact` be the JSON string representation of the numeric value of `resolvedSelector`.
(See [Determining Exact Literal Match](#determining-exact-literal-match) for details)
1. Let `exact` be the serialized representation of the numeric value of `resolvedSelector`.
(See [Exact Literal Match Serialization](#exact-literal-match-serialization) for details)
1. Let `keyword` be a string which is the result of [rule selection](#rule-selection) on `resolvedSelector`.
1. Let `resultExact` be a new empty list of strings.
1. Let `resultKeyword` be a new empty list of strings.
Expand Down Expand Up @@ -528,36 +528,31 @@ for examples.
> | 27 | `other` | 27 dní |
> | 2.4 | `many` | 2,4 dne |

#### Determining Exact Literal Match
#### Exact Literal Match Serialization

> [!IMPORTANT]
> The exact behavior of exact literal match is currently only well defined for non-zero-filled
> integer values.
> Functions that use fraction digits or significant digits might work in specific
> implementation-defined ways.
> Users should avoid depending on these types of keys in message selection in this release.
If the numeric value of `resolvedSelector` is an integer
and none of the following options are set for `resolvedSelector`,
the serialized form of the numeric value MUST match the ABNF defined below for `integer`,
representing its decimal value:
- `minimumFractionDigits`
- `minimumIntegerDigits`
- `minimumSignificantDigits`
- `maximumSignificantDigits`
- `notation`
- `style`

```abnf
integer = "0" / ["-"] ("1"-"9") *DIGIT
```

Number literals in the MessageFormat 2 syntax use the
[format defined for a JSON number](https://www.rfc-editor.org/rfc/rfc8259#section-6).
A `resolvedSelector` exactly matches a numeric literal `key`
if, when the numeric value of `resolvedSelector` is serialized using the format for a JSON number,
the two strings are equal.
Otherwise, the serialized form of the numeric value is implementation-defined.

> [!NOTE]
> The above description of numeric matching contains
> [open issues](https://github.com/unicode-org/message-format-wg/issues/675)
> in the Technical Preview, since a given numeric value might be formatted in
> several different ways under RFC8259
> and since the effect of formatting options, such as the number of fraction
> digits or significant digits, is not described.
> The Working Group intends to address these issues before final release
> with a number of design options
> [being considered](https://github.com/unicode-org/message-format-wg/pull/859).
>
> Users should avoid creating messages that depend on exact matching of non-integer
> numeric values.
> Feedback, including use cases encountered in message authoring, is strongly desired.
> [!IMPORTANT]
> The exact behavior of exact literal match is only well defined
> for non-zero-filled integer values.
> Functions that use fraction digits or significant digits
> might work in specific implementation-defined ways.
> Users should avoid depending on these types of keys in message selection.

## Date and Time Value Formatting

Expand Down
16 changes: 8 additions & 8 deletions test/tests/functions/integer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
"exp": "hello 4"
},
{
"src": ".input {$foo :integer} .match $foo 1 {{one}} * {{other}}",
"params": [
{
"name": "foo",
"value": 1.2
}
],
"exp": "one"
"src": ".input {$foo :integer} .match $foo 1 {{=1}} * {{other}}",
"params": [{ "name": "foo", "value": 1.2 }],
"exp": "=1"
},
{
"src": ".input {$foo :integer} .match $foo 1 {{=1}} one {{one}} * {{other}}",
"params": [{ "name": "foo", "value": 1.2 }],
"exp": "=1"
},
{
"src": ".local $x = {1.25 :integer} .local $y = {$x :number} {{{$y}}}",
Expand Down