-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Parse all kinds of declarations at function scope. #4779
base: trunk
Are you sure you want to change the base?
Conversation
These don't fully work yet, because they're not added into lexical lookup, but already mostly do the right thing. Per carbon-language#3407, disallow namespace declarations anywhere other than at file scope for now.
Also diagnose `package;`.
// CHECK:STDERR: fail_adapt.carbon:[[@LINE+4]]:3: error: `base` declaration outside class [ClassSpecificDeclOutsideClass] | ||
// CHECK:STDERR: extend base: C; | ||
// CHECK:STDERR: ^~~~~~~~~~~~~~~ | ||
// CHECK:STDERR: | ||
extend base: C; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there is some overlap with the testing added to toolchain/check/testdata/class/fail_base_misplaced.carbon
// CHECK:STDERR: fail_adapt.carbon:[[@LINE+4]]:3: error: `adapt` declaration outside class [ClassSpecificDeclOutsideClass] | ||
// CHECK:STDERR: adapt C; | ||
// CHECK:STDERR: ^~~~~~~~ | ||
// CHECK:STDERR: | ||
adapt C; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there is some overlap with the testing added to toolchain/check/testdata/class/adapter/adapt.carbon
These don't fully work in check and beyond yet, because they're not added into lexical lookup, but already mostly do the right thing.
Per #3407, disallow namespace declarations anywhere other than at file scope for now.
We don't treat statements starting with a packaging introducer keyword (
package
,library
,import
) as declarations because they're sufficiently unlikely to occur that the error recovery doesn't seem important, and this avoids needing to disambiguatepackage.
at the start of an expression.