mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Fix parse support for 'fn F[];' (#5135)
According to approved syntax at https://github.com/carbon-language/carbon-lang/blob/trunk/proposals/p3848.md#syntax-defined, `fn F[]` without explicit parameters should be valid. This makes it work, then adds some validation to prevent `class C[]` in check. Note that for `fn`, positional parameters are a TODO -- but this allows me to test validation in `fn destroy[]` which is rejected, not just a TODO.
This commit is contained in:
@@ -86,17 +86,13 @@ auto HandleDeclNameAndParams(Context& context) -> void {
|
||||
auto HandleDeclNameAndParamsAfterImplicit(Context& context) -> void {
|
||||
auto state = context.PopState();
|
||||
|
||||
state.state = State::DeclNameAndParamsAfterParams;
|
||||
context.PushState(state);
|
||||
|
||||
if (!context.PositionIs(Lex::TokenKind::OpenParen)) {
|
||||
CARBON_DIAGNOSTIC(
|
||||
ParamsRequiredAfterImplicit, Error,
|
||||
"a `(` for parameters is required after implicit parameters");
|
||||
context.emitter().Emit(*context.position(), ParamsRequiredAfterImplicit);
|
||||
context.ReturnErrorOnState();
|
||||
return;
|
||||
}
|
||||
|
||||
state.state = State::DeclNameAndParamsAfterParams;
|
||||
context.PushState(state);
|
||||
context.PushState(State::PatternListAsExplicit);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user