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

'augment class A {}' cannot be parsed #48541

Open
scheglov opened this issue Mar 10, 2022 · 5 comments
Open

'augment class A {}' cannot be parsed #48541

scheglov opened this issue Mar 10, 2022 · 5 comments
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues.

Comments

@scheglov
Copy link
Contributor

  Invalid argument(s): Content produced diagnostics when parsed:
    MISSING_CONST_FINAL_VAR_OR_TYPE: Variables must be declared using the keywords 'const', 'final', 'var' or a type name. - 1:1
    EXPECTED_TOKEN: Expected to find ';'. - 1:1

But macro class A {} can.

@scheglov scheglov added the area-front-end Use area-front-end for front end / CFE / kernel format related issues. label Mar 10, 2022
@johnniwinther
Copy link
Member

That is as intended(-ish). The support for augment class was originally added like the support macro class, but further development showed that augment class (for now) is only need in augmentation libraries. For this reason, augment class is now only supported when the scanner is configured for augmentation libraries, in which augment is treated as a modifier, whereas macro class is supported when the macros experimental flag is enabled.

@scheglov
Copy link
Contributor Author

OK, thank you.

This is inconvenient with the way analyzer works - we can parse a file not knowing initially how it will be referenced later. And it feels inconsistent with the way language version works, which allows you to set @dart = x.y in parts, but will check that it is the same as in the library.

So, for now in the analyzer I will enable augment anywhere when the macros feature is enabled.
https://dart-review.googlesource.com/c/sdk/+/242660

@bwilkerson
Copy link
Member

... augment class (for now) is only need in augmentation libraries.

How do we know that an arbitrary file is an augmentation library? Is there a file naming convention?

copybara-service bot pushed a commit that referenced this issue Apr 27, 2022
Bug: #48541
Change-Id: I01b6b5bb9062a1921e0e171419a9ec1349621d8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242660
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
@johnniwinther
Copy link
Member

Currently we only read these files knowing that they are augmentation libraries.

The general discussion of how to identify these is in dart-lang/language#2120

@scheglov
Copy link
Contributor Author

Thank you for the pointer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues.
Projects
None yet
Development

No branches or pull requests

3 participants