Skip to content

Commit be9dcc2

Browse files
committed
Define matching for simple integers, leave others up to implementations
1 parent 51b0d5d commit be9dcc2

File tree

2 files changed

+25
-35
lines changed

2 files changed

+25
-35
lines changed

spec/registry.md

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ where `resolvedSelector` is the _resolved value_ of a _selector_
451451
and `keys` is a list of strings,
452452
numeric selectors perform as described below.
453453
454-
1. Let `exact` be the JSON string representation of the numeric value of `resolvedSelector`.
454+
1. Let `exact` be the serialized representation of the numeric value of `resolvedSelector`.
455455
(See [Determining Exact Literal Match](#determining-exact-literal-match) for details)
456456
1. Let `keyword` be a string which is the result of [rule selection](#rule-selection) on `resolvedSelector`.
457457
1. Let `resultExact` be a new empty list of strings.
@@ -530,34 +530,24 @@ for examples.
530530
531531
#### Determining Exact Literal Match
532532
533-
> [!IMPORTANT]
534-
> The exact behavior of exact literal match is currently only well defined for non-zero-filled
535-
> integer values.
536-
> Functions that use fraction digits or significant digits might work in specific
537-
> implementation-defined ways.
538-
> Users should avoid depending on these types of keys in message selection in this release.
539-
533+
If the numeric value of `resolvedSelector` is a non-negative integer
534+
and none of the following options are set for `resolvedSelector`,
535+
the serialized form of the numeric value MUST match the ABNF for `digit-size-option`,
536+
representing its decimal value:
537+
- `minimumFractionDigits`
538+
- `minimumIntegerDigits`
539+
- `minimumSignificantDigits`
540+
- `notation`
541+
- `style`
540542
541-
Number literals in the MessageFormat 2 syntax use the
542-
[format defined for a JSON number](https://www.rfc-editor.org/rfc/rfc8259#section-6).
543-
A `resolvedSelector` exactly matches a numeric literal `key`
544-
if, when the numeric value of `resolvedSelector` is serialized using the format for a JSON number,
545-
the two strings are equal.
543+
Otherwise, the serialized form of the numeric value is implementation-defined.
546544
547-
> [!NOTE]
548-
> The above description of numeric matching contains
549-
> [open issues](https://github.com/unicode-org/message-format-wg/issues/675)
550-
> in the Technical Preview, since a given numeric value might be formatted in
551-
> several different ways under RFC8259
552-
> and since the effect of formatting options, such as the number of fraction
553-
> digits or significant digits, is not described.
554-
> The Working Group intends to address these issues before final release
555-
> with a number of design options
556-
> [being considered](https://github.com/unicode-org/message-format-wg/pull/859).
557-
>
558-
> Users should avoid creating messages that depend on exact matching of non-integer
559-
> numeric values.
560-
> Feedback, including use cases encountered in message authoring, is strongly desired.
545+
> [!IMPORTANT]
546+
> The exact behavior of exact literal match is only well defined
547+
> for non-zero-filled integer values.
548+
> Functions that use fraction digits or significant digits
549+
> might work in specific implementation-defined ways.
550+
> Users should avoid depending on these types of keys in message selection.
561551
562552
## Date and Time Value Formatting
563553

test/tests/functions/integer.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
"exp": "hello 4"
2121
},
2222
{
23-
"src": ".input {$foo :integer} .match $foo 1 {{one}} * {{other}}",
24-
"params": [
25-
{
26-
"name": "foo",
27-
"value": 1.2
28-
}
29-
],
30-
"exp": "one"
23+
"src": ".input {$foo :integer} .match $foo 1 {{=1}} * {{other}}",
24+
"params": [{ "name": "foo", "value": 1.2 }],
25+
"exp": "=1"
26+
},
27+
{
28+
"src": ".input {$foo :integer} .match $foo 1 {{=1}} one {{one}} * {{other}}",
29+
"params": [{ "name": "foo", "value": 1.2 }],
30+
"exp": "=1"
3131
},
3232
{
3333
"src": ".local $x = {1.25 :integer} .local $y = {$x :number} {{{$y}}}",

0 commit comments

Comments
 (0)