Skip to content
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

Enable various variables and factories with no implementation #4106

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

eernstg
Copy link
Member

@eernstg eernstg commented Sep 26, 2024

With support for augmentation, variables can be declared with no initializing expression in a couple of new cases where this was previously a syntax error, namely constant and final top-level variables as well as constant and final static variables. This PR changes the grammar to allow this kind of declaration. The point is that the omitted initializing expression can be provided by augmentation. Similarly for factory constructor declarations, they do not have to have a body when the body can be provided by augmentation. Finally, static getters, setters, and methods are also generalized to allow omitting the body, that is, they are allowed to look like "abstract static members", again because the body can be provided by augmentation.

The set of elements that are required for each definition are unchanged, but parsing will now succeed, and it is a non-syntax compile-time error if an element is omitted, e.g., if a constant top-level variable has no initializing expression.

@eernstg eernstg requested a review from munificent September 26, 2024 19:56
@eernstg eernstg merged commit 5995342 into main Sep 26, 2024
3 checks passed
@eernstg eernstg deleted the spec_unimplemented_var_sep24 branch September 26, 2024 21:29
@eernstg
Copy link
Member Author

eernstg commented Sep 26, 2024

Hello @sgrekhov! These changes were expected already a while ago, and I don't think there's a need to change any co19 tests as a consequence of these changes because those tests are already relying on the updated grammar.

However, the spec parser update in https://dart-review.googlesource.com/c/sdk/+/387160 seems to reveal a couple of syntax errors in augmentation related tests, in the commit which is currently rolled into the SDK (for example, augmenting_declarations_A05_t01.dart has some missing semicolons; enum E seems to need a value like e1; in augmenting_declarations_A05_t03_lib.dart, and a few others).

So it would probably be a good idea to wait for the spec_parser update and then take a look at the augmentation tests. Of course, it would be great if I could get a heads-up if the updated grammar somehow fails to handle the actual syntax in those tests, such that we can clarify whether it's the test or the grammar that needs to be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants