Update the specification section about metadata #3787
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The association that binds each metadatum in a Dart program to a language construct is specified in a way that is somewhat inconsistent with the grammar. For example, it associates the metadata declared in front of a
<libraryName>
with the keywordlibrary
, not with the library name directive as a whole.This PR changes the wording such that metadata which occurs at the beginning of a grammar rule is associated with the construct as a whole. If the metadata occurs in any other location in the rule then we continue to use the rule which is specified prior to this PR: The metadata is associated with the program construct which is derived from the following non-terminal. The latter rule works well with cases like
<classDeclaration> ::= ... (<metadata> <classMemberDeclaration>)* ...
.This PR also adds a small amount of rationale text, saying that this whole topic has an implementation specific element, and the normative rules are intentionally somewhat flexible. We trust all tool maintainers to maintain a reasonable amount of consistency, and provide just a few normative rules in order to make it easier to be consistent, insofar as this is possible with the given program representation.
Fixes #3773.