From 7fbeb882f7f22aa6450c3b643ffb213494fba2a1 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Wed, 19 Jul 2023 16:03:46 +0300 Subject: [PATCH 1/5] Add Missing Selector Annotation error --- spec/formatting.md | 45 ++++++++++++++++++++++++++++++++++++--------- spec/syntax.md | 2 ++ 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/spec/formatting.md b/spec/formatting.md index 6cc866a688..c30104cc51 100644 --- a/spec/formatting.md +++ b/spec/formatting.md @@ -381,15 +381,15 @@ _This section is non-normative._ #### Example 1 -Presuming a minimal implementation which only supports string values -and matches keys by using string comparison, +Presuming a minimal implementation which only supports `:string` annotation +which matches keys by using string comparison, and a formatting context in which the variable reference `$foo` resolves to the string `'foo'` and the variable reference `$bar` resolves to the string `'bar'`, pattern selection proceeds as follows for this message: ``` -match {$foo} {$bar} +match {$foo :string} {$bar :string} when bar bar {All bar} when foo foo {All foo} when * * {Otherwise} @@ -420,7 +420,7 @@ Alternatively, with the same implementation and formatting context as in Example pattern selection would proceed as follows for this message: ``` -match {$foo} {$bar} +match {$foo :string} {$bar :string} when * bar {Any and bar} when foo * {Foo and any} when foo bar {Foo and bar} @@ -645,13 +645,13 @@ These are divided into the following categories: > Example invalid messages resulting in a Variant Key Mismatch error: > > ``` - > match {$one} + > match {$one :func} > when 1 2 {Too many} > when * {Otherwise} > ``` > > ``` - > match {$one} {$two} + > match {$one :func} {$two :func} > when 1 2 {Two keys} > when * {Missing a key} > when * * {Otherwise} @@ -663,17 +663,44 @@ These are divided into the following categories: > Example invalid messages resulting in a Missing Fallback Variant error: > > ``` - > match {$one} + > match {$one :func} > when 1 {Value is one} > when 2 {Value is two} > ``` > > ``` - > match {$one} {$two} + > match {$one :func} {$two :func} > when 1 * {First is one} > when * 1 {Second is one} > ``` + - **Missing Selector Annotation errors** occur when the message + contains a _selector_ that does not have an _annotation_, + or contains a _variable_ that does not reference a _declaration_ with an _annotation_. + + > Example invalid messages resulting in a Missing Selector Annotation error: + > + > ``` + > match {$one} + > when 1 {Value is one} + > when * {Value is not one} + > ``` + > + > ``` + > let $one = {|The one|} + > match {$one} + > when 1 {Value is one} + > when * {Value is not one} + > ``` + > + > ``` + > let $one = {|The one| :func} + > let $two = {$one} + > match {$two} + > when 1 {Value is one} + > when * {Value is not one} + > ``` + - **Duplicate Option Name errors** occur when the same _name_ appears on the left-hand side of more than one _option_ in the same _expression_. @@ -703,7 +730,7 @@ These are divided into the following categories: > ``` > > ``` - > match {$var} + > match {$var :func} > when 1 {The value is one.} > when * {The value is not one.} > ``` diff --git a/spec/syntax.md b/spec/syntax.md index 1cedae38f4..9c0f714d26 100644 --- a/spec/syntax.md +++ b/spec/syntax.md @@ -309,6 +309,8 @@ A _well-formed_ message is considered _valid_ if the following requirements are - The number of keys on each _variant_ MUST be equal to the number of _selectors_. - At least one _variant's_ keys MUST all be equal to the catch-all key (`*`). +- Each _selector_ MUST have an _annotation_, + or contain a _variable_ that references a _declaration_ with an _annotation_. ### Patterns From b5886c188158f02fb5e28b41f25edf80ae847e2c Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Fri, 21 Jul 2023 20:49:32 +0300 Subject: [PATCH 2/5] Apply suggestions from code review --- spec/formatting.md | 2 +- spec/syntax.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/formatting.md b/spec/formatting.md index c30104cc51..c1056d7d25 100644 --- a/spec/formatting.md +++ b/spec/formatting.md @@ -676,7 +676,7 @@ These are divided into the following categories: - **Missing Selector Annotation errors** occur when the message contains a _selector_ that does not have an _annotation_, - or contains a _variable_ that does not reference a _declaration_ with an _annotation_. + or contains a _variable_ that does not directly or indirectly reference a _declaration_ with an _annotation_. > Example invalid messages resulting in a Missing Selector Annotation error: > diff --git a/spec/syntax.md b/spec/syntax.md index 9c0f714d26..ee25d4ed7f 100644 --- a/spec/syntax.md +++ b/spec/syntax.md @@ -310,7 +310,7 @@ A _well-formed_ message is considered _valid_ if the following requirements are - The number of keys on each _variant_ MUST be equal to the number of _selectors_. - At least one _variant's_ keys MUST all be equal to the catch-all key (`*`). - Each _selector_ MUST have an _annotation_, - or contain a _variable_ that references a _declaration_ with an _annotation_. + or contain a _variable_ that directly or indirectly references a _declaration_ with an _annotation_. ### Patterns From b29634eb30974a06097437b5a440297b777db8f3 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Sun, 23 Jul 2023 09:05:38 +0300 Subject: [PATCH 3/5] Update spec/formatting.md 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 c1056d7d25..d7eb1a34c9 100644 --- a/spec/formatting.md +++ b/spec/formatting.md @@ -674,7 +674,7 @@ These are divided into the following categories: > when * 1 {Second is one} > ``` - - **Missing Selector Annotation errors** occur when the message +A **_Missing Selection Annotation error_** is an error that occurs when the _message_ contains a _selector_ that does not have an _annotation_, or contains a _variable_ that does not directly or indirectly reference a _declaration_ with an _annotation_. From 26254046c4a29b81dbb79b7eb716c21ad2dde98d Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Sun, 23 Jul 2023 22:29:58 +0300 Subject: [PATCH 4/5] Update spec/formatting.md --- spec/formatting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/formatting.md b/spec/formatting.md index d7eb1a34c9..32b6866d83 100644 --- a/spec/formatting.md +++ b/spec/formatting.md @@ -674,7 +674,7 @@ These are divided into the following categories: > when * 1 {Second is one} > ``` -A **_Missing Selection Annotation error_** is an error that occurs when the _message_ + - A **_Missing Selector Annotation error_** is an error that occurs when the _message_ contains a _selector_ that does not have an _annotation_, or contains a _variable_ that does not directly or indirectly reference a _declaration_ with an _annotation_. From aa6f6304af081c9408dcaa589a9ded7b3c2ce6e7 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Sun, 23 Jul 2023 22:30:29 +0300 Subject: [PATCH 5/5] Update spec/formatting.md --- spec/formatting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/formatting.md b/spec/formatting.md index 32b6866d83..b2c60e6fec 100644 --- a/spec/formatting.md +++ b/spec/formatting.md @@ -678,7 +678,7 @@ These are divided into the following categories: contains a _selector_ that does not have an _annotation_, or contains a _variable_ that does not directly or indirectly reference a _declaration_ with an _annotation_. - > Example invalid messages resulting in a Missing Selector Annotation error: + > Example invalid messages resulting in a _Missing Selector Annotation error_: > > ``` > match {$one}