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

Skip to content

Commit 4dbdc35

Browse files
authored
Require select option to be set by a literal value (#1016)
* Require select option to be set by a literal value * Linkify _message_
1 parent b343bfa commit 4dbdc35

File tree

3 files changed

+72
-4
lines changed

3 files changed

+72
-4
lines changed

spec/functions/number.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ the value of other options, or both.
2222
2323
The following options and their values are REQUIRED to be available on the function `:number`:
2424

25-
- `select`
26-
- `plural` (default; see [Default Value of `select` Option](#default-value-of-select-option) below)
25+
- `select` (see [Number Selection](#number-selection) below)
26+
- `plural` (default)
2727
- `ordinal`
2828
- `exact`
2929
- `compactDisplay` (this option only has meaning when combined with the option `notation=compact`)
@@ -128,8 +128,8 @@ the value of other options, or both.
128128
129129
The following options and their values are REQUIRED to be available on the function `:integer`:
130130
131-
- `select`
132-
- `plural` (default; see [Default Value of `select` Option](#default-value-of-select-option) below)
131+
- `select` (see [Number Selection](#number-selection) below)
132+
- `plural` (default)
133133
- `ordinal`
134134
- `exact`
135135
- `numberingSystem`
@@ -657,6 +657,14 @@ or any option-specific lower limit, a _Bad Option Error_ is emitted.
657657

658658
### Number Selection
659659

660+
The value of the `select` _option_ MUST be set by a _literal_,
661+
as otherwise the _message_ might not be translatable.
662+
If this value is set by a _variable_ or
663+
the option value of an implementation-defined type used as an _operand_,
664+
a _Bad Option Error_ is emitted and
665+
the _resolved value_ of the expression MUST NOT support selection.
666+
The formatting of the _resolved value_ is not affected by the `select` _option_.
667+
660668
Number selection has three modes:
661669

662670
- `exact` selection matches the operand to explicit numeric keys exactly

test/tests/functions/integer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,36 @@
3636
{
3737
"src": ".local $x = {1.25 :integer} .local $y = {$x :number} {{{$y}}}",
3838
"exp": "1"
39+
},
40+
{
41+
"src": "literal select {1 :integer select=exact}",
42+
"exp": "literal select {1}"
43+
},
44+
{
45+
"src": ".local $bad = {exact} {{variable select {1 :integer select=$bad}}}",
46+
"exp": "variable select {1}",
47+
"expErrors": [{ "type": "bad-option" }]
48+
},
49+
{
50+
"src": "variable select {1 :integer select=$bad}",
51+
"params": [{ "name": "bad", "value": "exact" }],
52+
"exp": "variable select {1}",
53+
"expErrors": [{ "type": "bad-option" }]
54+
},
55+
{
56+
"src": ".local $sel = {1 :integer select=exact} .match $sel 1 {{literal select {$sel}}} * {{OTHER}}",
57+
"exp": "literal select {1}"
58+
},
59+
{
60+
"src": ".local $sel = {1 :integer select=exact} .local $bad = {$sel :integer} .match $bad 1 {{ONE}} * {{operand select {$bad}}}",
61+
"exp": "operand select {1}",
62+
"expErrors": [{ "type": "bad-option" }, { "type": "bad-selector" }]
63+
},
64+
{
65+
"src": ".local $sel = {1 :integer select=$bad} .match $sel 1 {{ONE}} * {{variable select {$sel}}}",
66+
"params": [{ "name": "bad", "value": "exact" }],
67+
"exp": "variable select {1}",
68+
"expErrors": [{ "type": "bad-option" }, { "type": "bad-selector" }]
3969
}
4070
]
4171
}

test/tests/functions/number.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,36 @@
185185
}
186186
]
187187
},
188+
{
189+
"src": "literal select {1 :number select=exact}",
190+
"exp": "literal select {1}"
191+
},
192+
{
193+
"src": ".local $bad = {exact} {{variable select {1 :number select=$bad}}}",
194+
"exp": "variable select {1}",
195+
"expErrors": [{ "type": "bad-option" }]
196+
},
197+
{
198+
"src": "variable select {1 :number select=$bad}",
199+
"params": [{ "name": "bad", "value": "exact" }],
200+
"exp": "variable select {1}",
201+
"expErrors": [{ "type": "bad-option" }]
202+
},
203+
{
204+
"src": ".local $sel = {1 :number select=exact} .match $sel 1 {{literal select {$sel}}} * {{OTHER}}",
205+
"exp": "literal select {1}"
206+
},
207+
{
208+
"src": ".local $sel = {1 :number select=exact} .local $bad = {$sel :number} .match $bad 1 {{ONE}} * {{operand select {$bad}}}",
209+
"exp": "operand select {1}",
210+
"expErrors": [{ "type": "bad-option" }, { "type": "bad-selector" }]
211+
},
212+
{
213+
"src": ".local $sel = {1 :number select=$bad} .match $sel 1 {{ONE}} * {{variable select {$sel}}}",
214+
"params": [{ "name": "bad", "value": "exact" }],
215+
"exp": "variable select {1}",
216+
"expErrors": [{ "type": "bad-option" }, { "type": "bad-selector" }]
217+
},
188218
{
189219
"src": "{42 :number @foo @bar=13}",
190220
"exp": "42",

0 commit comments

Comments
 (0)