Skip to content

Commit 258d49a

Browse files
eemeliaphillips
andauthored
Clarify Duplicate Declaration error (#580)
* Add missing Forward Reference data model error * Apply suggestions from code review * Refactor PR to redefine Duplicate Declaration rules * Drop Forward Reference error definition * Update Duplicate Declaration error description * Apply suggestions from code review Co-authored-by: Addison Phillips <[email protected]> --------- Co-authored-by: Addison Phillips <[email protected]>
1 parent c36981e commit 258d49a

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

spec/errors.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,9 @@ or contains a _variable_ that does not directly or indirectly reference a _decla
129129
130130
### Duplicate Declaration
131131
132-
A **_<dfn>Duplicate Declaration</dfn>_** error occurs when a _variable_ appears in two _declarations_.
133-
This includes when an _input-declaration_ binds a _variable_ that appears in a previous _declaration_,
134-
when a _local-declaration_ binds a _variable_ that appears in a previous _declaration_,
135-
or when a _local-declaration_ refers to its bound _variable_ in its _expression_.
132+
A **_<dfn>Duplicate Declaration</dfn>_** error occurs when a _variable_ is declared more than once.
133+
Note that an input _variable_ is implicitly declared when it is first used,
134+
so explicitly declaring it after such use is also an error.
136135
137136
> Examples of invalid messages resulting in a _Duplicate Declaration_ error:
138137
>
@@ -149,6 +148,10 @@ or when a _local-declaration_ refers to its bound _variable_ in its _expression_
149148
> .local $var = {$ext :number maxFractionDigits=0}
150149
> {{Redeclaration of an input variable}}
151150
>
151+
> .input {$var :number minFractionDigits=$var2}
152+
> .input {$var2 :number}
153+
> {{Redeclaration of the implicit input variable $var2}}
154+
>
152155
> .local $var = {$ext :someFunction}
153156
> .local $var = {$error}
154157
> .local $var2 = {$var2 :error}

spec/syntax.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,14 @@ local-declaration = local s variable [s] "=" [s] expression
175175
_Variables_, once declared, MUST NOT be redeclared.
176176
A _message_ that does any of the following is not _valid_ and will produce a
177177
_Duplicate Declaration_ error during processing:
178-
- An _input-declaration_ MUST NOT bind a _variable_ that appears as a _variable_ in a previous
179-
_declaration_.
180-
- A _local-declaration_ MUST NOT bind a _variable_ that appears as a _variable_ in a previous
181-
_declaration_.
178+
- A _declaration_ MUST NOT bind a _variable_
179+
that appears as a _variable_ anywhere within a previous _declaration_.
180+
- An _input-declaration_ MUST NOT bind a _variable_
181+
that appears anywhere within the _annotation_ of its _variable-expression_.
182182
- A _local-declaration_ MUST NOT bind a _variable_ that appears in its _expression_.
183183

184184
A _local-declaration_ MAY overwrite an external input value as long as the
185-
external input value does not appear in a _declaration_.
185+
external input value does not appear in a previous _declaration_.
186186

187187
> [!Note]
188188
> These restrictions only apply to _declarations_.

0 commit comments

Comments
 (0)