mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 13:11:05 +01:00
Rename Deduced parameters to Implicit parameters. (#3336)
In preparation for supporting `self`, which is implicit but not deduced.
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user