File tree Expand file tree Collapse file tree 4 files changed +42
-1
lines changed Expand file tree Collapse file tree 4 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,27 @@ appears on the left-hand side of more than one _option_ in the same _expression_
178
178
> {{This is {$foo}}}
179
179
> ```
180
180
181
+ ### Duplicate Variant
182
+
183
+ A **_<dfn>Duplicate Variant</dfn>_** error occurs when the
184
+ same list of _keys_ is used for more than one _variant_.
185
+
186
+ > Examples of invalid messages resulting in a _Duplicate Variant_ error:
187
+ >
188
+ > ```
189
+ > .match {$var :string}
190
+ > * {{The first default}}
191
+ > * {{The second default}}
192
+ > ```
193
+ >
194
+ > ```
195
+ > .match {$x :string} {$y :string}
196
+ > * foo {{The first "foo" variant}}
197
+ > bar * {{The "bar" variant}}
198
+ > * |foo| {{The second "foo" variant}}
199
+ > * * {{The default variant}}
200
+ > ```
201
+
181
202
## Resolution Errors
182
203
183
204
**_<dfn>Resolution Errors</dfn>_** occur when the runtime value of a part of a message
Original file line number Diff line number Diff line change @@ -375,6 +375,9 @@ satisfied:
375
375
- At least one _ variant_ MUST exist whose _ keys_ are all equal to the "catch-all" key ` * ` .
376
376
- Each _ selector_ MUST have an _ annotation_ ,
377
377
or contain a _ variable_ that directly or indirectly references a _ declaration_ with an _ annotation_ .
378
+ - Each _ variant_ MUST use a list of _ keys_ that is unique from that
379
+ of all other _ variants_ in the _ message_ .
380
+ _ Literal_ _ keys_ are compared by their contents, not their syntactical appearance.
378
381
379
382
``` abnf
380
383
matcher = match-statement 1*([s] variant)
@@ -440,7 +443,7 @@ There MAY be any number of additional _selectors_.
440
443
441
444
### Variant
442
445
443
- A **_<dfn>variant</dfn>_** is a _quoted pattern_ associated with a set of _keys_ in a _matcher_.
446
+ A **_<dfn>variant</dfn>_** is a _quoted pattern_ associated with a list of _keys_ in a _matcher_.
444
447
Each _variant_ MUST begin with a sequence of _keys_,
445
448
and terminate with a valid _quoted pattern_.
446
449
The number of _keys_ in each _variant_ MUST match the number of _selectors_ in the _matcher_.
Original file line number Diff line number Diff line change 342
342
" missing-selector-annotation" ,
343
343
" duplicate-declaration" ,
344
344
" duplicate-option-name" ,
345
+ " duplicate-variant" ,
345
346
" unresolved-variable" ,
346
347
" unknown-function" ,
347
348
" unsupported-expression" ,
Original file line number Diff line number Diff line change 164
164
"type" : " duplicate-option-name"
165
165
}
166
166
]
167
+ },
168
+ {
169
+ "src" : " .match {$var :string} * {{The first default}} * {{The second default}}" ,
170
+ "expErrors" : [
171
+ {
172
+ "type" : " duplicate-variant"
173
+ }
174
+ ]
175
+ },
176
+ {
177
+ "src" : " .match {$x :string} {$y :string} * foo {{The first foo variant}} bar * {{The bar variant}} * |foo| {{The second foo variant}} * * {{The default variant}}" ,
178
+ "expErrors" : [
179
+ {
180
+ "type" : " duplicate-variant"
181
+ }
182
+ ]
167
183
}
168
184
]
169
185
}
You can’t perform that action at this time.
0 commit comments