Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add Missing Selector Annotation error #431

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 5 commits into from
Jul 24, 2023
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
45 changes: 36 additions & 9 deletions spec/formatting.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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}
Expand All @@ -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}
> ```

- 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_.

> 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_.
Expand Down Expand Up @@ -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.}
> ```
Expand Down
2 changes: 2 additions & 0 deletions spec/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 directly or indirectly references a _declaration_ with an _annotation_.

### Patterns

Expand Down