Fix a case of InvalidParse with has_error = false (#4481)

Introduced in #4470.

Co-authored-by: Josh L <josh11b@users.noreply.github.com>
This commit is contained in:
josh11b
2024-11-04 21:22:50 +00:00
committed by GitHub
co-authored by Josh L
parent fcd611406a
commit 607522c7de
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -336,7 +336,8 @@ auto Context::ConsumeListToken(NodeKind comma_kind, Lex::TokenKind close_kind,
if (PositionIs(close_kind)) {
return ListTokenKind::Close;
} else {
AddLeafNode(comma_kind, Consume());
AddLeafNode(comma_kind, Consume(),
/*has_error=*/comma_kind == NodeKind::InvalidParse);
return PositionIs(close_kind) ? ListTokenKind::CommaClose
: ListTokenKind::Comma;
}
+1 -1
View File
@@ -20,7 +20,7 @@ var x: {,} = {};
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'InvalidParse', text: ',', has_error: yes},
// CHECK:STDOUT: {kind: 'InvalidParse', text: ','},
// CHECK:STDOUT: {kind: 'InvalidParse', text: ',', has_error: yes},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 4},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 6},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},