-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
The language grammar (referring to the current version of dartLangSpec.tex, from commit c63f801) specifies for certain declarations that a built-in identifier should be placed before the metadata of that declaration, or the metadata is missing entirely. Consider for example top level definitions:
topLevelDefinition:
...
'external'? functionSignature ';' |
'external'? getterSignature ';' |
'external'? setterSignature ';'
With the first alternative we can derive this:
external @foo void f();With getterSignature and setterSignature there is no metadata at all. This seems to be inconsistent (the metadata typically comes first, and metadata is allowed on most kinds of declarations), and @bwilkerson noted that the tools currently do not follow the grammar in the language specification: they require the metadata to come first, and they do allow getters and setters to have metadata at the top level.
There is a somewhat similar issue with class members:
classDefinition:
metadata 'abstract'? 'class' identifier typeParameters?
(superclass mixins?)? interfaces?
'{' (metadata classMemberDefinition)* '}'
classMemberDefinition:
declaration ';' |
methodSignature functionBody
methodSignature:
... |
'static'? functionSignature |
...
declaration:
... |
('external' 'static'?)? functionSignature |
...
Here we can derive a class member like @foo static @bar void f() {} and @foo external static @bar void f();, where @bar looks spurious.
We may be able to simply remove metadata from functionSignature and then add metadata to several other parts of the grammar, but it would be useful to correlate the grammar corrections with the actual implementations such that the spec and the implementations differ as little as possible.