@@ -23,11 +23,15 @@ are treated as identical.
23
23
To resolve the value of a _ variable_ ,
24
24
its _ name_ is used to identify either a local variable,
25
25
or a variable defined elsewhere.
26
- If a local variable and an externally defined one use the same name,
27
- the local variable takes precedence.
28
26
29
- It is an error for a local variable definition to
30
- refer to a local variable that's defined after it in the message.
27
+ It is an error for the right-hand side of a local variable declaration to
28
+ refer to a local variable that's declared after it in the message.
29
+
30
+ Variable names are required to be globally unique. That is,
31
+ for any local variable declaration of the form ` let $v = e ` :
32
+ * It is an error if ` v ` is the left-hand side of a local variable declaration
33
+ that appears before ` let $v = e ` in the message.
34
+ * It is also an error if ` v ` is an externally defined variable.
31
35
32
36
## Pattern Selection
33
37
@@ -428,6 +432,32 @@ These are divided into the following categories:
428
432
> when * {The value is not one.}
429
433
> ```
430
434
435
+ - **Variable Redefinition errors** occur when
436
+ the left-hand side of a variable declaration is already defined,
437
+ either by a previous local variable declaration,
438
+ or by an external definition.
439
+
440
+ > For example, attempting to format the following message
441
+ > must result in a Variable Redefinition error,
442
+ > because there is another declaration for `var`
443
+ > that textually precedes
444
+ > the declaration of `var` to be `{|horse|}`.
445
+ >
446
+ > ```
447
+ > let $var = {|cart|}
448
+ > let $var = {|horse|}
449
+ > {The value is {$var}.}
450
+ > ```
451
+ >
452
+ > Attempting to format the following message in a context
453
+ > where `var` is externally defined
454
+ > should also result in a Variable Redefinition error.
455
+ >
456
+ > ```
457
+ > let $var = {|horse|}
458
+ > {The value is {$var}.}
459
+ > ```
460
+
431
461
- **Unknown Function errors** occur when an _expression_ includes
432
462
a reference to a function which cannot be resolved.
433
463
@@ -590,3 +620,21 @@ rather than the _expression_ in the _selector_ or _pattern_.
590
620
> ```
591
621
> The value is {|horse|}.
592
622
> ```
623
+
624
+ When there are multiple _declarations_ for the same _variable_,
625
+ the fallback string is formatted based on the _expression_ of
626
+ the first declaration of that _variable_.
627
+
628
+ > For example, attempting to format the following message:
629
+ >
630
+ > ```
631
+ > let $var = {|cart|}
632
+ > let $var = {|horse|}
633
+ > {The value is {$var}.}
634
+ > ```
635
+ >
636
+ > would result in this formatted string representation:
637
+ >
638
+ > ```
639
+ > The value is {|cart|}.
640
+ > ```
0 commit comments