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

Parse all kinds of declarations at function scope. #4779

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

zygoloid
Copy link
Contributor

@zygoloid zygoloid commented Jan 9, 2025

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 disambiguate package. at the start of an expression.

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.
@github-actions github-actions bot requested a review from josh11b January 9, 2025 02:05
Comment on lines +29 to +33
// 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;
Copy link
Contributor

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

Comment on lines +19 to +23
// CHECK:STDERR: fail_adapt.carbon:[[@LINE+4]]:3: error: `adapt` declaration outside class [ClassSpecificDeclOutsideClass]
// CHECK:STDERR: adapt C;
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR:
adapt C;
Copy link
Contributor

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

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

Successfully merging this pull request may close these issues.

2 participants