@@ -123,11 +123,15 @@ The resolution of a _text_ or _literal_ token MUST always succeed.
123
123
To resolve the value of a _variable_,
124
124
its _name_ is used to identify either a local variable,
125
125
or a variable defined elsewhere.
126
- If a local variable and an externally defined one use the same name,
127
- the local variable takes precedence.
128
126
129
- It is an error for a local variable definition to
130
- refer to a local variable that's defined after it in the message.
127
+ It is an error for the right-hand side of a local variable declaration to
128
+ refer to a local variable that's declared after it in the message.
129
+
130
+ Variable names are required to be globally unique. That is,
131
+ for any local variable declaration of the form `let $v = e`:
132
+ * It is an error if `v` is the left-hand side of a local variable declaration
133
+ that appears before `let $v = e` in the message.
134
+ * It is also an error if `v` is an externally defined variable.
131
135
132
136
The resolution of a _variable_ MAY fail if no value is identified for its _name_.
133
137
If this happens, an Unresolved Variable error MUST be emitted.
@@ -230,6 +234,24 @@ rather than the _expression_ in the _selector_ or _pattern_.
230
234
231
235
_Pattern selection_ is not supported for _fallback values_.
232
236
237
+ When there are multiple _declarations_ for the same _variable_,
238
+ the fallback string is formatted based on the _expression_ of
239
+ the first declaration of that _variable_.
240
+
241
+ > For example, attempting to format the following message:
242
+ >
243
+ > ```
244
+ > let $var = {|cart|}
245
+ > let $var = {|horse|}
246
+ > {The value is {$var}.}
247
+ > ```
248
+ >
249
+ > would result in this formatted string representation:
250
+ >
251
+ > ```
252
+ > The value is {|cart|}.
253
+ > ```
254
+
233
255
## Pattern Selection
234
256
235
257
When a _message_ contains a _match_ construct with one or more _expressions_,
@@ -704,6 +726,32 @@ These are divided into the following categories:
704
726
> when * {The value is not one.}
705
727
> ```
706
728
729
+ - **Variable Redefinition errors** occur when
730
+ the left-hand side of a variable declaration is already defined,
731
+ either by a previous local variable declaration,
732
+ or by an external definition.
733
+
734
+ > For example, attempting to format the following message
735
+ > must result in a Variable Redefinition error,
736
+ > because there is another declaration for `var`
737
+ > that textually precedes
738
+ > the declaration of `var` to be `{|horse|}`.
739
+ >
740
+ > ```
741
+ > let $var = {|cart|}
742
+ > let $var = {|horse|}
743
+ > {The value is {$var}.}
744
+ > ```
745
+ >
746
+ > Attempting to format the following message in a context
747
+ > where `var` is externally defined
748
+ > should also result in a Variable Redefinition error.
749
+ >
750
+ > ```
751
+ > let $var = {|horse|}
752
+ > {The value is {$var}.}
753
+ > ```
754
+
707
755
- **Unknown Function errors** occur when an _expression_ includes
708
756
a reference to a function which cannot be resolved.
709
757
0 commit comments