Change struct literal parsing to use placeholders. (#3850)

This is achieving a similar goal as #3849, using placeholders instead of
an ambiguous start node to clarify structure and incrementally simplify
checking. The benefit isn't quite as big here because both paths are
structs, and so checking is more consistent than paren exprs versus
tuples. But I think this removes the only other multi-purpose parse
node.

This uses StructLiteral/StructTypeLiteral naming, reflecting equivalent
SemIR naming. Note, I would lean towards renaming StructLiteral to
StructValueLiteral, but I think consistency in naming takes precedence.
Any renames of StructLiteral might be better in a separate PR.

StructFieldType/StructFieldValue -> StructTypeField/StructField is
trying to making the reading more consistent with
StructTypeLiteral/StructLiteral. SemIR has StructTypeField but not a
value equivalent.
This commit is contained in:
Jon Ross-Perkins
2024-04-03 20:36:49 +00:00
committed by GitHub
parent b42612bcec
commit a034f86272
31 changed files with 129 additions and 130 deletions
+16 -16
View File
@@ -7,14 +7,19 @@
namespace Carbon::Check {
auto HandleStructLiteralOrStructTypeLiteralStart(
Context& context, Parse::StructLiteralOrStructTypeLiteralStartId node_id)
auto HandleStructTypeLiteralStart(Context& context,
Parse::StructTypeLiteralStartId node_id)
-> bool {
context.scope_stack().Push();
context.node_stack().Push(node_id);
// At this point we aren't sure whether this will be a value or type literal,
// so we push onto args irrespective. It just won't be used for a type
// literal.
context.param_and_arg_refs_stack().Push();
return true;
}
auto HandleStructLiteralStart(Context& context,
Parse::StructLiteralStartId node_id) -> bool {
context.scope_stack().Push();
context.node_stack().Push(node_id);
context.args_type_info_stack().Push();
context.param_and_arg_refs_stack().Push();
return true;
@@ -34,8 +39,7 @@ auto HandleStructComma(Context& context, Parse::StructCommaId /*node_id*/)
return true;
}
auto HandleStructFieldValue(Context& context, Parse::StructFieldValueId node_id)
-> bool {
auto HandleStructField(Context& context, Parse::StructFieldId node_id) -> bool {
auto value_inst_id = context.node_stack().PopExpr();
auto [name_node, name_id] = context.node_stack().PopNameWithNodeId();
@@ -49,7 +53,7 @@ auto HandleStructFieldValue(Context& context, Parse::StructFieldValueId node_id)
return true;
}
auto HandleStructFieldType(Context& context, Parse::StructFieldTypeId node_id)
auto HandleStructTypeField(Context& context, Parse::StructTypeFieldId node_id)
-> bool {
auto [type_node, type_id] = context.node_stack().PopExprWithNodeId();
SemIR::TypeId cast_type_id = ExprAsType(context, type_node, type_id);
@@ -92,12 +96,11 @@ static auto DiagnoseDuplicateNames(Context& context,
auto HandleStructLiteral(Context& context, Parse::StructLiteralId node_id)
-> bool {
auto refs_id = context.param_and_arg_refs_stack().EndAndPop(
Parse::NodeKind::StructLiteralOrStructTypeLiteralStart);
Parse::NodeKind::StructLiteralStart);
context.scope_stack().Pop();
context.node_stack()
.PopAndDiscardSoloNodeId<
Parse::NodeKind::StructLiteralOrStructTypeLiteralStart>();
.PopAndDiscardSoloNodeId<Parse::NodeKind::StructLiteralStart>();
auto type_block_id = context.args_type_info_stack().Pop();
if (DiagnoseDuplicateNames(context, type_block_id, "struct literal")) {
context.node_stack().Push(node_id, SemIR::InstId::BuiltinError);
@@ -115,14 +118,11 @@ auto HandleStructLiteral(Context& context, Parse::StructLiteralId node_id)
auto HandleStructTypeLiteral(Context& context,
Parse::StructTypeLiteralId node_id) -> bool {
auto refs_id = context.param_and_arg_refs_stack().EndAndPop(
Parse::NodeKind::StructLiteralOrStructTypeLiteralStart);
Parse::NodeKind::StructTypeLiteralStart);
context.scope_stack().Pop();
context.node_stack()
.PopAndDiscardSoloNodeId<
Parse::NodeKind::StructLiteralOrStructTypeLiteralStart>();
// This is only used for value literals.
context.args_type_info_stack().Pop();
.PopAndDiscardSoloNodeId<Parse::NodeKind::StructTypeLiteralStart>();
CARBON_CHECK(refs_id != SemIR::InstBlockId::Empty)
<< "{} is handled by StructLiteral.";
+4 -4
View File
@@ -412,8 +412,8 @@ class NodeStack {
case Parse::NodeKind::ReturnType:
case Parse::NodeKind::ShortCircuitOperandAnd:
case Parse::NodeKind::ShortCircuitOperandOr:
case Parse::NodeKind::StructFieldValue:
case Parse::NodeKind::StructFieldType:
case Parse::NodeKind::StructField:
case Parse::NodeKind::StructTypeField:
return Id::KindFor<SemIR::InstId>();
case Parse::NodeKind::IfCondition:
case Parse::NodeKind::IfExprIf:
@@ -445,12 +445,12 @@ class NodeStack {
case Parse::NodeKind::InterfaceIntroducer:
case Parse::NodeKind::LetInitializer:
case Parse::NodeKind::LetIntroducer:
case Parse::NodeKind::ParenExprStart:
case Parse::NodeKind::QualifiedName:
case Parse::NodeKind::ReturnedModifier:
case Parse::NodeKind::ReturnStatementStart:
case Parse::NodeKind::ReturnVarModifier:
case Parse::NodeKind::StructLiteralOrStructTypeLiteralStart:
case Parse::NodeKind::StructLiteralStart:
case Parse::NodeKind::StructTypeLiteralStart:
case Parse::NodeKind::TupleLiteralStart:
case Parse::NodeKind::TuplePatternStart:
case Parse::NodeKind::VariableInitializer:
+2 -2
View File
@@ -30,7 +30,7 @@ class ParamAndArgRefsStack {
// On a comma, pushes the most recent instruction, becoming param or arg ref.
// This also pops the NodeStack, meaning its top will remain start_kind.
auto ApplyComma() -> void {
// Support expressions, parameters, and other nodes like `StructFieldValue`
// Support expressions, parameters, and other nodes like `StructField`
// that produce InstIds.
stack_.AddInstId(node_stack_->Pop<SemIR::InstId>());
}
@@ -43,7 +43,7 @@ class ParamAndArgRefsStack {
auto EndNoPop(Parse::NodeKind start_kind) -> void {
if (!node_stack_->PeekIs(start_kind)) {
// Support expressions, parameters, and other nodes like
// `StructFieldValue` that produce InstIds.
// `StructField` that produce InstIds.
stack_.AddInstId(node_stack_->Pop<SemIR::InstId>());
}
}
+13 -11
View File
@@ -10,9 +10,8 @@ auto HandleBraceExpr(Context& context) -> void {
auto state = context.PopState();
context.PushState(state, State::BraceExprFinishAsUnknown);
CARBON_CHECK(context.ConsumeAndAddLeafNodeIf(
Lex::TokenKind::OpenCurlyBrace,
NodeKind::StructLiteralOrStructTypeLiteralStart));
CARBON_CHECK(context.ConsumeAndAddLeafNodeIf(Lex::TokenKind::OpenCurlyBrace,
NodeKind::Placeholder));
if (!context.PositionIs(Lex::TokenKind::CloseCurlyBrace)) {
context.PushState(State::BraceExprParamAsUnknown);
}
@@ -163,12 +162,12 @@ static auto HandleBraceExprParamFinish(Context& context, NodeKind node_kind,
}
auto HandleBraceExprParamFinishAsType(Context& context) -> void {
HandleBraceExprParamFinish(context, NodeKind::StructFieldType,
HandleBraceExprParamFinish(context, NodeKind::StructTypeField,
State::BraceExprParamAsType);
}
auto HandleBraceExprParamFinishAsValue(Context& context) -> void {
HandleBraceExprParamFinish(context, NodeKind::StructFieldValue,
HandleBraceExprParamFinish(context, NodeKind::StructField,
State::BraceExprParamAsValue);
}
@@ -178,24 +177,27 @@ auto HandleBraceExprParamFinishAsUnknown(Context& context) -> void {
}
// Handles BraceExprFinishAs(Type|Value|Unknown).
static auto HandleBraceExprFinish(Context& context, NodeKind node_kind)
-> void {
static auto HandleBraceExprFinish(Context& context, NodeKind start_kind,
NodeKind end_kind) -> void {
auto state = context.PopState();
context.AddNode(node_kind, context.Consume(), state.subtree_start,
context.ReplacePlaceholderNode(state.subtree_start, start_kind, state.token);
context.AddNode(end_kind, context.Consume(), state.subtree_start,
state.has_error);
}
auto HandleBraceExprFinishAsType(Context& context) -> void {
HandleBraceExprFinish(context, NodeKind::StructTypeLiteral);
HandleBraceExprFinish(context, NodeKind::StructTypeLiteralStart,
NodeKind::StructTypeLiteral);
}
auto HandleBraceExprFinishAsValue(Context& context) -> void {
HandleBraceExprFinish(context, NodeKind::StructLiteral);
HandleBraceExprFinish(context, NodeKind::StructLiteralStart,
NodeKind::StructLiteral);
}
auto HandleBraceExprFinishAsUnknown(Context& context) -> void {
HandleBraceExprFinish(context, NodeKind::StructLiteral);
HandleBraceExprFinishAsValue(context);
}
} // namespace Carbon::Parse
+15 -18
View File
@@ -595,42 +595,40 @@ CARBON_PARSE_NODE_KIND_CHILD_COUNT(IfExprThen, 1, Then)
CARBON_PARSE_NODE_KIND_CHILD_COUNT(IfExprElse, 3, CARBON_IF_VALID(Else))
// Struct literals, such as `{.a = 0}`:
// StructLiteralOrStructTypeLiteralStart
// StructLiteralStart
// _external_: IdentifierName or BaseName
// StructFieldDesignator
// _external_: expression
// StructFieldValue
// StructField
// StructComma
// _repeated_
// StructLiteral
//
// Struct type literals, such as `{.a: i32}`:
// StructLiteralOrStructTypeLiteralStart
// StructTypeLiteralStart
// _external_: IdentifierName or BaseName
// StructFieldDesignator
// _external_: type expression
// StructFieldType
// StructTypeField
// StructComma
// _repeated_
// StructTypeLiteral
//
// Elements (StructFieldValue and StructFieldType, respectively) and StructComma
// Elements (StructField and StructTypeField, respectively) and StructComma
// may repeat with StructComma as a separator.
//
// When a valid StructFieldType or StructFieldValue cannot be formed, elements
// When a valid StructTypeField or StructField cannot be formed, elements
// may be replaced by InvalidParse, which may have a preceding sibling
// StructFieldDesignator if one was successfully parsed.
CARBON_PARSE_NODE_KIND_CHILD_COUNT(StructLiteralOrStructTypeLiteralStart, 0,
OpenCurlyBrace)
CARBON_PARSE_NODE_KIND_CHILD_COUNT(StructLiteralStart, 0, OpenCurlyBrace)
CARBON_PARSE_NODE_KIND_CHILD_COUNT(StructTypeLiteralStart, 0, OpenCurlyBrace)
CARBON_PARSE_NODE_KIND_CHILD_COUNT(StructFieldDesignator, 1, Period)
CARBON_PARSE_NODE_KIND_CHILD_COUNT(StructFieldValue, 2, Equal)
CARBON_PARSE_NODE_KIND_CHILD_COUNT(StructFieldType, 2, Colon)
CARBON_PARSE_NODE_KIND_CHILD_COUNT(StructField, 2, Equal)
CARBON_PARSE_NODE_KIND_CHILD_COUNT(StructTypeField, 2, Colon)
CARBON_PARSE_NODE_KIND_CHILD_COUNT(StructComma, 0, Comma)
CARBON_PARSE_NODE_KIND_BRACKET(StructLiteral,
StructLiteralOrStructTypeLiteralStart,
CARBON_PARSE_NODE_KIND_BRACKET(StructLiteral, StructLiteralStart,
CloseCurlyBrace)
CARBON_PARSE_NODE_KIND_BRACKET(StructTypeLiteral,
StructLiteralOrStructTypeLiteralStart,
CARBON_PARSE_NODE_KIND_BRACKET(StructTypeLiteral, StructTypeLiteralStart,
CloseCurlyBrace)
// Various modifiers. These are all a single token.
@@ -805,15 +803,14 @@ CARBON_PARSE_NODE_KIND_CHILD_COUNT(MatchCaseIntroducer, 0, Case)
CARBON_PARSE_NODE_KIND_CHILD_COUNT(MatchCaseGuardIntroducer, 0, If)
CARBON_PARSE_NODE_KIND_CHILD_COUNT(MatchCaseGuardStart, 0,
CARBON_IF_VALID(OpenParen))
CARBON_PARSE_NODE_KIND_BRACKET(MatchCaseGuard,
MatchCaseGuardIntroducer,
CARBON_PARSE_NODE_KIND_BRACKET(MatchCaseGuard, MatchCaseGuardIntroducer,
CARBON_IF_VALID(CloseParen))
CARBON_PARSE_NODE_KIND_CHILD_COUNT(MatchCaseEqualGreater, 0,
CARBON_IF_VALID(EqualGreater))
CARBON_PARSE_NODE_KIND_BRACKET(MatchCaseStart, MatchCaseIntroducer,
CARBON_IF_VALID(OpenCurlyBrace))
CARBON_IF_VALID(OpenCurlyBrace))
CARBON_PARSE_NODE_KIND_BRACKET(MatchCase, MatchCaseStart,
CARBON_IF_VALID(CloseCurlyBrace))
CARBON_IF_VALID(CloseCurlyBrace))
// `default`:
// MatchDefaultIntroducer
+2 -2
View File
@@ -26,11 +26,11 @@ class Foo {
// CHECK:STDOUT: {kind: 'ReturnType', text: '->', subtree_size: 2},
// CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 7},
// CHECK:STDOUT: {kind: 'ReturnStatementStart', text: 'return'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntLiteral', text: '0'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructField', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 6},
// CHECK:STDOUT: {kind: 'ReturnStatement', text: ';', subtree_size: 8},
// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 16},
+1 -1
View File
@@ -33,7 +33,7 @@ fn F() {
// CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2},
// CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5},
// CHECK:STDOUT: {kind: 'ForHeaderStart', text: 'for', has_error: yes},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'ForHeader', text: 'for', has_error: yes, subtree_size: 4},
// CHECK:STDOUT: {kind: 'CodeBlockStart', text: '}', has_error: yes},
+2 -2
View File
@@ -14,13 +14,13 @@ var x: {,} = {};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'InvalidParse', text: ',', has_error: yes},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 4},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 6},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
@@ -14,18 +14,18 @@ var x: {.a: i32,,} = {};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructTypeField', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'InvalidParse', text: ',', has_error: yes},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', has_error: yes, subtree_size: 9},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 11},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 16},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
@@ -14,18 +14,18 @@ var x: {.a = 0,,} = {};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntLiteral', text: '0'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructField', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'InvalidParse', text: ',', has_error: yes},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 9},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 11},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 16},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
+2 -2
View File
@@ -14,14 +14,14 @@ var x: {.} = {};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: '}', has_error: yes},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'InvalidParse', text: '.', has_error: yes},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 5},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 7},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 12},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
+1 -1
View File
@@ -14,7 +14,7 @@ var x: {.(a) = 1};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: '(', has_error: yes},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntLiteral', text: '1'},
@@ -14,7 +14,7 @@ var x: {."hello": i32, .y: i32} = {};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: '"hello"', has_error: yes},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
@@ -23,11 +23,11 @@ var x: {."hello": i32, .y: i32} = {};
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'y'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructTypeField', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', has_error: yes, subtree_size: 11},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 13},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 18},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
@@ -14,7 +14,7 @@ var x: {."hello" = 0, .y = 4} = {};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: '"hello"', has_error: yes},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntLiteral', text: '0'},
@@ -23,11 +23,11 @@ var x: {."hello" = 0, .y = 4} = {};
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'y'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntLiteral', text: '4'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructField', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 11},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 13},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 18},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
@@ -14,19 +14,19 @@ var x: {.a: i32 banana} = {.a = 0};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructTypeField', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', has_error: yes, subtree_size: 6},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 8},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntLiteral', text: '0'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructField', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 6},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 17},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
@@ -14,19 +14,19 @@ var x: {.a: i32} = {.a = 0 banana};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructTypeField', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 6},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 8},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntLiteral', text: '0'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructField', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 6},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 17},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
@@ -14,12 +14,12 @@ var x: {a:} = {};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'InvalidParse', text: 'a', has_error: yes},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 3},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 5},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
@@ -14,12 +14,12 @@ var x: {a=} = {};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'InvalidParse', text: 'a', has_error: yes},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 3},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 5},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
@@ -14,12 +14,12 @@ var x: {a} = {};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'InvalidParse', text: 'a', has_error: yes},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 3},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 5},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
+2 -2
View File
@@ -14,7 +14,7 @@ var x: {.a:} = {};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'InvalidParse', text: '}', has_error: yes},
@@ -22,7 +22,7 @@ var x: {.a:} = {};
// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', has_error: yes, subtree_size: 6},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 8},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 13},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
+2 -2
View File
@@ -14,7 +14,7 @@ var x: {.a=} = {};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'InvalidParse', text: '}', has_error: yes},
@@ -22,7 +22,7 @@ var x: {.a=} = {};
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 6},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 8},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 13},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
@@ -14,11 +14,11 @@ var x: {.a: i32, .b = 0} = {};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructTypeField', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'b'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
@@ -26,7 +26,7 @@ var x: {.a: i32, .b = 0} = {};
// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', has_error: yes, subtree_size: 10},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 12},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 17},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
@@ -14,17 +14,17 @@ var x: {.a = 0, b: i32} = {};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntLiteral', text: '0'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructField', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'InvalidParse', text: 'b', has_error: yes},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 8},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 10},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 15},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
@@ -31,11 +31,11 @@ var x: i32 = {.a: i32, .b, .c = 1};
// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntLiteral', text: '1'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructField', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'b'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
@@ -51,11 +51,11 @@ var x: i32 = {.a: i32, .b, .c = 1};
// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructTypeField', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'b'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
@@ -14,14 +14,14 @@ var x: {.a} = {};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'InvalidParse', text: '.', has_error: yes},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 5},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 7},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 12},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
@@ -14,12 +14,12 @@ var x: {i32} = {};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'InvalidParse', text: 'i32', has_error: yes},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 3},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 5},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
+2 -2
View File
@@ -11,11 +11,11 @@ var y: {} = {};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'y'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
+4 -4
View File
@@ -11,19 +11,19 @@ var z: {.n: i32} = {.n = 4};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'z'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'n'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructTypeField', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 6},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 8},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'n'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntLiteral', text: '4'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructField', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 6},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 17},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
@@ -11,20 +11,20 @@ var z: {.n: i32,} = {.n = 4,};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'z'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'n'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructTypeField', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 7},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 9},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'n'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntLiteral', text: '4'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructField', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 7},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 19},
+6 -6
View File
@@ -11,29 +11,29 @@ var x: {.a: i32, .b: i32} = {.a = 1, .b = 2};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructTypeField', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'b'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructTypeField', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 11},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 13},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntLiteral', text: '1'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructField', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'b'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntLiteral', text: '2'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructField', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 11},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 27},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
+11 -11
View File
@@ -821,12 +821,12 @@ struct ChoiceDefinition {
CommaSeparatedList<Alternative, ChoiceAlternativeListCommaId> alternatives;
};
// Struct literals and struct type literals
// Struct type and value literals
// ----------------------------------------
// `{`
using StructLiteralOrStructTypeLiteralStart =
LeafNode<NodeKind::StructLiteralOrStructTypeLiteralStart>;
using StructLiteralStart = LeafNode<NodeKind::StructLiteralStart>;
using StructTypeLiteralStart = LeafNode<NodeKind::StructTypeLiteralStart>;
// `,`
using StructComma = LeafNode<NodeKind::StructComma>;
@@ -838,16 +838,16 @@ struct StructFieldDesignator {
};
// `.a = 0`
struct StructFieldValue {
static constexpr auto Kind = NodeKind::StructFieldValue.Define();
struct StructField {
static constexpr auto Kind = NodeKind::StructField.Define();
StructFieldDesignatorId designator;
AnyExprId expr;
};
// `.a: i32`
struct StructFieldType {
static constexpr auto Kind = NodeKind::StructFieldType.Define();
struct StructTypeField {
static constexpr auto Kind = NodeKind::StructTypeField.Define();
StructFieldDesignatorId designator;
AnyExprId type_expr;
@@ -858,8 +858,8 @@ struct StructLiteral {
static constexpr auto Kind =
NodeKind::StructLiteral.Define(NodeCategory::Expr);
StructLiteralOrStructTypeLiteralStartId introducer;
CommaSeparatedList<StructFieldValueId, StructCommaId> fields;
StructLiteralStartId start;
CommaSeparatedList<StructFieldId, StructCommaId> fields;
};
// Struct type literals, such as `{.a: i32}`.
@@ -867,8 +867,8 @@ struct StructTypeLiteral {
static constexpr auto Kind =
NodeKind::StructTypeLiteral.Define(NodeCategory::Expr);
StructLiteralOrStructTypeLiteralStartId introducer;
CommaSeparatedList<StructFieldTypeId, StructCommaId> fields;
StructTypeLiteralStartId start;
CommaSeparatedList<StructTypeFieldId, StructCommaId> fields;
};
// `class` declarations and definitions