@@ -193,6 +193,52 @@ Examples:
193
193
- Can produce a mismatch between formatting and selection, since the operand's formatting
194
194
isn't visible to the selector.
195
195
196
+ ### Require annotation of selector variables in placeholders
197
+
198
+ In this alternative, the pre-existing validity requirement
199
+
200
+ > Each _ selector_ MUST have an _ annotation_ ,
201
+ > or contain a _ variable_ that directly or indirectly references a _ declaration_ with an _ annotation_ .
202
+
203
+ is expanded to also require later uses of a variable that's used as a selector to be annotated:
204
+
205
+ > In a _ complex message_ ,
206
+ > each _ placeholder_ _ expression_ using the same _ operand_ as a _ selector_ MUST have an _ annotation_ ,
207
+ > or contain a _ variable_ that directly or indirectly references a _ declaration_ with an _ annotation_ .
208
+
209
+ Example invalid message with this alternative:
210
+ ```
211
+ .match {$n :number minimumFractionDigits=2}
212
+ * {{Data model error: {$n}}}
213
+ ```
214
+
215
+ Valid, recommended form for the above message:
216
+ ```
217
+ .input {$n :number minimumFractionDigits=2}
218
+ .match {$n}
219
+ * {{Formats '$n' as a number with fraction digits: {$n}}}
220
+ ```
221
+
222
+ Technically valid but not recommended:
223
+ ```
224
+ .input {$n :integer}
225
+ .match {$n :number minimumFractionDigits=2}
226
+ * {{Formats '$n' as an integer: {$n}}}
227
+
228
+ .match {$n :number minimumFractionDigits=2}
229
+ * {{Formats '$n' as an integer: {$n :integer}}}
230
+ ```
231
+
232
+ ** Pros**
233
+ - No syntax changes required.
234
+ - ` .local ` can be used to solve problems with variations in selection and formatting
235
+ - Supports multiple selectors on the same operand
236
+ - Avoids mismatches between formatting and selection by requiring their annotation.
237
+
238
+ ** Cons**
239
+ - May require the user to annotate the operand for both formatting and selection,
240
+ unless they use a declaration.
241
+
196
242
### Allow both local and input declarative selectors with immutability
197
243
198
244
In this alternative, we modify the syntax to allow selectors to
0 commit comments