mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 21:00:13 +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:
@@ -385,11 +385,13 @@ static auto ValidateIfDestroy(Context& context, bool is_redecl,
|
||||
return;
|
||||
}
|
||||
|
||||
CARBON_CHECK(
|
||||
orig_param_patterns_id.has_value(),
|
||||
"TODO: Positional parameters are currently rejected as part of requiring "
|
||||
"implicit parameters, because it's an invalid parse tree; add a "
|
||||
"diagnostic once this is testable");
|
||||
if (!orig_param_patterns_id.has_value()) {
|
||||
CARBON_DIAGNOSTIC(DestroyFunctionPositionalParams, Error,
|
||||
"missing empty explicit parameter list");
|
||||
context.emitter().Emit(function_info.latest_decl_id(),
|
||||
DestroyFunctionPositionalParams);
|
||||
return;
|
||||
}
|
||||
|
||||
if (orig_param_patterns_id != SemIR::InstBlockId::Empty) {
|
||||
CARBON_DIAGNOSTIC(DestroyFunctionNonEmptyExplicitParams, Error,
|
||||
|
||||
Reference in New Issue
Block a user