Parsing and basic checking for abstract class and base class. (#3385)

For now, we require the same introducer to be used each time a class is
declared, but see #3384.

---------

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
Richard SmithandJon Ross-Perkins authored and GitHub committed 2023-11-13 20:38:21 +00:00
1 parent 49591d1360
commit 2715e2276e
23 files changed
+520 -114

No files matched your search

+3 -3
View File
@@ -62,7 +62,7 @@ auto HandlePatternBinding(Context& context, Parse::Node parse_node) -> bool {
// error locations.
switch (auto context_parse_node_kind = context.parse_tree().node_kind(
context.node_stack().PeekParseNode())) {
case Parse::NodeKind::ReturnedSpecifier:
case Parse::NodeKind::ReturnedModifier:
case Parse::NodeKind::VariableIntroducer: {
// A `var` declaration at class scope introduces a field.
auto enclosing_class_decl = context.GetCurrentScopeAs<SemIR::ClassDecl>();
@@ -79,7 +79,7 @@ auto HandlePatternBinding(Context& context, Parse::Node parse_node) -> bool {
}
SemIR::InstId value_id = SemIR::InstId::Invalid;
SemIR::TypeId value_type_id = cast_type_id;
if (context_parse_node_kind == Parse::NodeKind::ReturnedSpecifier) {
if (context_parse_node_kind == Parse::NodeKind::ReturnedModifier) {
CARBON_CHECK(!enclosing_class_decl) << "`returned var` at class scope";
value_id =
CheckReturnedVar(context, context.node_stack().PeekParseNode(),
@@ -108,7 +108,7 @@ auto HandlePatternBinding(Context& context, Parse::Node parse_node) -> bool {
SemIR::BindName{name_node, value_type_id, name_id, value_id});
context.node_stack().Push(parse_node, bind_id);
if (context_parse_node_kind == Parse::NodeKind::ReturnedSpecifier) {
if (context_parse_node_kind == Parse::NodeKind::ReturnedModifier) {
RegisterReturnedVar(context, bind_id);
}
break;