Skip to content

Clarify Duplicate Declaration error #580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions spec/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,9 @@ or contains a _variable_ that does not directly or indirectly reference a _decla

### Duplicate Declaration

A **_<dfn>Duplicate Declaration</dfn>_** error occurs when a _variable_ appears in two _declarations_.
This includes when an _input-declaration_ binds a _variable_ that appears in a previous _declaration_,
when a _local-declaration_ binds a _variable_ that appears in a previous _declaration_,
or when a _local-declaration_ refers to its bound _variable_ in its _expression_.
A **_<dfn>Duplicate Declaration</dfn>_** error occurs when a _variable_ is declared more than once.
Note that an input _variable_ is implicitly declared when it is first used,
so explicitly declaring it after such use is also an error.

> Examples of invalid messages resulting in a _Duplicate Declaration_ error:
>
Expand All @@ -149,6 +148,10 @@ or when a _local-declaration_ refers to its bound _variable_ in its _expression_
> .local $var = {$ext :number maxFractionDigits=0}
> {{Redeclaration of an input variable}}
>
> .input {$var :number minFractionDigits=$var2}
> .input {$var2 :number}
> {{Redeclaration of the implicit input variable $var2}}
>
> .local $var = {$ext :someFunction}
> .local $var = {$error}
> .local $var2 = {$var2 :error}
Expand Down
10 changes: 5 additions & 5 deletions spec/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,14 @@ local-declaration = local s variable [s] "=" [s] expression
_Variables_, once declared, MUST NOT be redeclared.
A _message_ that does any of the following is not _valid_ and will produce a
_Duplicate Declaration_ error during processing:
- An _input-declaration_ MUST NOT bind a _variable_ that appears as a _variable_ in a previous
_declaration_.
- A _local-declaration_ MUST NOT bind a _variable_ that appears as a _variable_ in a previous
_declaration_.
- A _declaration_ MUST NOT bind a _variable_
that appears as a _variable_ anywhere within a previous _declaration_.
- An _input-declaration_ MUST NOT bind a _variable_
that appears anywhere within the _annotation_ of its _variable-expression_.
- A _local-declaration_ MUST NOT bind a _variable_ that appears in its _expression_.

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

> [!Note]
> These restrictions only apply to _declarations_.
Expand Down