-
-
Notifications
You must be signed in to change notification settings - Fork 36
Clarify declaration immutability #511
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
Changes from all commits
e854365
0c1b8bb
a67a185
5d37907
e9908c8
4bb512e
ebd31e1
a2305b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,19 +148,39 @@ MAY include an _annotation_ that is applied to the external value. | |
|
||
A **_<dfn>local-declaration</dfn>_** binds a _variable_ to the resolved value of an _expression_. | ||
|
||
Declared _variables_ MUST NOT be used before their _declaration_, | ||
and their values MUST NOT be self-referential; | ||
otherwise, a _message_ is not considered _valid_. | ||
|
||
Multiple _declarations_ MUST NOT bind a value to the same _variable_; | ||
otherwise, a _message_ is not considered _valid_. | ||
|
||
```abnf | ||
declaration = input-declaration / local-declaration | ||
input-declaration = input [s] variable-expression | ||
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_. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought local declarations were allowed to override external variables? Or was that a rejected proposal? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a little complicated and I should probably add text about the corner case here. Currently you can annotate an external value using
... and you can assign it to a
... and you can overwrite an external variable so long as it is not declared:
But not this:
|
||
- 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_. | ||
|
||
> [!Note] | ||
> These restrictions only apply to _declarations_. | ||
> A _placeholder_ or _selector_ can apply a different annotation to a _variable_ | ||
> than one applied to the same _variable_ name in a _declaration_. | ||
> For example, this message is _valid_: | ||
> ``` | ||
> {{ | ||
> input {$var :number maxFractionDigits=0} | ||
> match {$var :plural maxFractionDigits=2} | ||
> when 0 {{The selector can apply a different annotation to {$var} for the purposes of selection}} | ||
> when * {{A placeholder in a pattern can apply a different annotation to {$var :number maxFractionDigits=3}}} | ||
> }} | ||
> ``` | ||
> (See [Error Handling](./formatting.md#error-handling) for examples of invalid messages) | ||
|
||
### Body | ||
|
||
The **_<dfn>body</dfn>_** of a _complex message_ is the part that will be formatted. | ||
|
Uh oh!
There was an error while loading. Please reload this page.