Rename Deduced parameters to Implicit parameters. (#3336)

In preparation for supporting `self`, which is implicit but not deduced.
This commit is contained in:
Richard Smith
2023-10-25 21:46:12 +00:00
committed by GitHub
parent ab575cf32a
commit 387a1711af
24 changed files with 127 additions and 126 deletions
+7 -6
View File
@@ -6,7 +6,7 @@
namespace Carbon::Parse {
// Handles PatternAs(DeducedParameter|FunctionParameter|Variable|Let).
// Handles PatternAs(ImplicitParameter|FunctionParameter|Variable|Let).
static auto HandlePattern(Context& context, Context::PatternKind pattern_kind)
-> void {
auto state = context.PopState();
@@ -23,7 +23,7 @@ static auto HandlePattern(Context& context, Context::PatternKind pattern_kind)
// Handle an invalid pattern introducer for parameters and variables.
auto on_error = [&]() {
switch (pattern_kind) {
case Context::PatternKind::DeducedParameter:
case Context::PatternKind::ImplicitParameter:
case Context::PatternKind::Parameter: {
CARBON_DIAGNOSTIC(ExpectedParameterName, Error,
"Expected parameter declaration.");
@@ -51,12 +51,13 @@ static auto HandlePattern(Context& context, Context::PatternKind pattern_kind)
context.PushState(state);
};
// The first item should be an identifier or, for deduced parameters, `self`.
// The first item should be an identifier or, in an implicit parameter list,
// `self`.
bool has_name = false;
if (auto identifier = context.ConsumeIf(Lex::TokenKind::Identifier)) {
context.AddLeafNode(NodeKind::Name, *identifier);
has_name = true;
} else if (pattern_kind == Context::PatternKind::DeducedParameter) {
} else if (pattern_kind == Context::PatternKind::ImplicitParameter) {
if (auto self = context.ConsumeIf(Lex::TokenKind::SelfValueIdentifier)) {
context.AddLeafNode(NodeKind::SelfValueName, *self);
has_name = true;
@@ -84,8 +85,8 @@ static auto HandlePattern(Context& context, Context::PatternKind pattern_kind)
}
}
auto HandlePatternAsDeducedParameter(Context& context) -> void {
HandlePattern(context, Context::PatternKind::DeducedParameter);
auto HandlePatternAsImplicitParameter(Context& context) -> void {
HandlePattern(context, Context::PatternKind::ImplicitParameter);
}
auto HandlePatternAsParameter(Context& context) -> void {