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_
178178> {{This is {$foo}}}
179179> ```
180180
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+
181202## Resolution Errors
182203
183204**_<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:
375375- At least one _ variant_ MUST exist whose _ keys_ are all equal to the "catch-all" key ` * ` .
376376- Each _ selector_ MUST have an _ annotation_ ,
377377 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.
378381
379382``` abnf
380383matcher = match-statement 1*([s] variant)
@@ -440,7 +443,7 @@ There MAY be any number of additional _selectors_.
440443
441444### Variant
442445
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_.
444447Each _variant_ MUST begin with a sequence of _keys_,
445448and terminate with a valid _quoted pattern_.
446449The 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 342342 " missing-selector-annotation" ,
343343 " duplicate-declaration" ,
344344 " duplicate-option-name" ,
345+ " duplicate-variant" ,
345346 " unresolved-variable" ,
346347 " unknown-function" ,
347348 " unsupported-expression" ,
Original file line number Diff line number Diff line change 164164 "type" : " duplicate-option-name"
165165 }
166166 ]
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+ ]
167183 }
168184 ]
169185}
You can’t perform that action at this time.
0 commit comments