From 87a4f8edd26993a2857fbf695bf19f43b6d67154 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Fri, 5 Jan 2024 21:00:25 +0200 Subject: [PATCH 1/6] Add missing Forward Reference data model error --- spec/formatting.md | 15 +++++++++++++++ spec/syntax.md | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/spec/formatting.md b/spec/formatting.md index 74900c6e50..4d9a9d9f6b 100644 --- a/spec/formatting.md +++ b/spec/formatting.md @@ -834,6 +834,21 @@ These are divided into the following categories: > {{{$var} cannot be redefined. {$var2} cannot refer to itself}} > ``` + - A **Forward Reference error** occurs when a _declaration_ _expression_ includes a _variable_ + that is declared after it in the _message_. + + > Examples of invalid messages resulting in a Forward Reference error: + > + > ``` + > .local $foo = {$bar :number} + > .local $bar = {42 :number} + > {{The answer is {$foo}}} + > + > .local $foo = {42 :number minimumFractionDigits=$bar} + > .local $bar = {2} + > {{The answer is {$foo}}} + > ``` + - A **Duplicate Option Name error** occurs when the same _identifier_ appears on the left-hand side of more than one _option_ in the same _expression_. diff --git a/spec/syntax.md b/spec/syntax.md index 1add87f16d..8ca71e01e4 100644 --- a/spec/syntax.md +++ b/spec/syntax.md @@ -183,6 +183,10 @@ Duplicate Declaration error during formatting: A _local-declaration_ MAY overwrite an external input value as long as the external input value does not appear in a _declaration_. +A _declaration_ _expression_ MUST NOT include a _variable_ +that is declared after it in the _message_. +Doing so produces a Forward Reference error during formatting. + > [!Note] > These restrictions only apply to _declarations_. > A _placeholder_ or _selector_ can apply a different annotation to a _variable_ From 249d67c39e546d728b3b565b40c8a9d16b828cbe Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Fri, 5 Jan 2024 22:23:43 +0200 Subject: [PATCH 2/6] Apply suggestions from code review --- spec/formatting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/formatting.md b/spec/formatting.md index 4d9a9d9f6b..e7a07c19dd 100644 --- a/spec/formatting.md +++ b/spec/formatting.md @@ -844,7 +844,7 @@ These are divided into the following categories: > .local $bar = {42 :number} > {{The answer is {$foo}}} > - > .local $foo = {42 :number minimumFractionDigits=$bar} + > .input {$foo :number minimumFractionDigits=$bar} > .local $bar = {2} > {{The answer is {$foo}}} > ``` From 2966b79133b410f25ff192c7f6ef2e686fd2eb34 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Mon, 15 Jan 2024 13:48:57 +0200 Subject: [PATCH 3/6] Refactor PR to redefine Duplicate Declaration rules --- spec/syntax.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/spec/syntax.md b/spec/syntax.md index 8ca71e01e4..f19d777955 100644 --- a/spec/syntax.md +++ b/spec/syntax.md @@ -174,18 +174,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 formatting: -- 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_. - -A _declaration_ _expression_ MUST NOT include a _variable_ -that is declared after it in the _message_. -Doing so produces a Forward Reference error during formatting. +external input value does not appear in a previous _declaration_. > [!Note] > These restrictions only apply to _declarations_. From 0fa01d6d4fc5de6ef7c38e8ff6bfd1dd74b30a5c Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Mon, 15 Jan 2024 13:50:45 +0200 Subject: [PATCH 4/6] Drop Forward Reference error definition --- spec/formatting.md | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/spec/formatting.md b/spec/formatting.md index e7a07c19dd..74900c6e50 100644 --- a/spec/formatting.md +++ b/spec/formatting.md @@ -834,21 +834,6 @@ These are divided into the following categories: > {{{$var} cannot be redefined. {$var2} cannot refer to itself}} > ``` - - A **Forward Reference error** occurs when a _declaration_ _expression_ includes a _variable_ - that is declared after it in the _message_. - - > Examples of invalid messages resulting in a Forward Reference error: - > - > ``` - > .local $foo = {$bar :number} - > .local $bar = {42 :number} - > {{The answer is {$foo}}} - > - > .input {$foo :number minimumFractionDigits=$bar} - > .local $bar = {2} - > {{The answer is {$foo}}} - > ``` - - A **Duplicate Option Name error** occurs when the same _identifier_ appears on the left-hand side of more than one _option_ in the same _expression_. From 23aa51c877db66785e827e3b562832355f223a6b Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Mon, 15 Jan 2024 14:02:20 +0200 Subject: [PATCH 5/6] Update Duplicate Declaration error description --- spec/formatting.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/spec/formatting.md b/spec/formatting.md index 74900c6e50..2d6039723c 100644 --- a/spec/formatting.md +++ b/spec/formatting.md @@ -808,10 +808,9 @@ These are divided into the following categories: > * {{Value is not one}} > ``` - - A **Duplicate Declaration 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 **Duplicate Declaration 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: > @@ -828,6 +827,10 @@ These are divided into the following categories: > .local $var = {$ext :number maxFractionDigits=0} > {{Redeclaration of an input variable}} > + > .input {$var :number minFractionDigits=$var2} + > .input {$var2 :number} + > {{Redeclaration of an implicit input variable}} + > > .local $var = {$ext :someFunction} > .local $var = {$error} > .local $var2 = {$var2 :error} From a9a01e10a483c3c28c4ea1930de135a54f008cf8 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Mon, 15 Jan 2024 17:13:17 +0200 Subject: [PATCH 6/6] Apply suggestions from code review Co-authored-by: Addison Phillips --- spec/formatting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/formatting.md b/spec/formatting.md index 2d6039723c..390e4aefac 100644 --- a/spec/formatting.md +++ b/spec/formatting.md @@ -829,7 +829,7 @@ These are divided into the following categories: > > .input {$var :number minFractionDigits=$var2} > .input {$var2 :number} - > {{Redeclaration of an implicit input variable}} + > {{Redeclaration of the implicit input variable $var2}} > > .local $var = {$ext :someFunction} > .local $var = {$error}