Skip to content

Commit 0e19f21

Browse files
committed
Clarify definition of use-before-definition error
1 parent dab9b38 commit 0e19f21

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

spec/formatting.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,22 @@ To resolve the value of a _variable_,
124124
its _name_ is used to identify either a local variable,
125125
or a variable defined elsewhere.
126126
127-
The _name_ of a variable MUST either be:
128-
* The _name_ of a _variable_ of a _declaration_
127+
When a _variable_is used as an _operand_,
128+
the _name_ of this variable MUST either be:
129+
1. The _name_ of a _variable_ of a _declaration_ that occurs before the
130+
_operand_, or:
131+
1. An externally defined variable.
129132
130-
It is an error for the right-hand side of a local variable declaration to
131-
refer to a local variable that's declared after it in the message.
133+
In case 1, the `entire` _declaration_ MUST appear before the _operand_.
134+
For example, resolution of the following declaration should fail:
135+
136+
```
137+
let $var = {$var}
138+
```
139+
140+
because although a _variable_ with _name_ `var` occurs before
141+
the expression `{$var}`, the entire declaration `let $var = {$var}`
142+
does not occur before the expression `{$var}`.
132143
133144
Variable names are required to be globally unique. That is,
134145
for any local variable declaration of the form `let $v = e`:

0 commit comments

Comments
 (0)