Files
carbon-lang/toolchain/parse/testdata/struct/fail_missing_value.carbon
T
Jon Ross-Perkins a034f86272 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.
2024-04-03 20:36:49 +00:00

30 lines
1.5 KiB
Plaintext

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// CHECK:STDERR: fail_missing_value.carbon:[[@LINE+3]]:12: ERROR: Expected expression.
// CHECK:STDERR: var x: {.a=} = {};
// CHECK:STDERR: ^
var x: {.a=} = {};
// CHECK:STDOUT: - filename: fail_missing_value.carbon
// CHECK:STDOUT: parse_tree: [
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
// 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: 'InvalidParse', text: '=', has_error: yes},
// 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: 'StructLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 13},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]