Files
carbon-lang/toolchain/parse/testdata/struct/fail_dot_paren.carbon
T
Richard Smith 3884d3c27e Parse and check support for compound member access. (#3790)
On the parsing side, we treat `a.(b)` as a member access whose second
operand is a `ParenExpr` rather than a `MemberName`. A new node category
is added for the union of `MemberName` and `ParenExpr` to support this.

Checking is mostly reusing the same pieces we already have for simple
member access. Compound member access is in most ways a simplified form
of simple member access because it doesn't need to do any lookup.
2024-03-16 22:38:23 +00:00

27 lines
1.3 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_dot_paren.carbon:[[@LINE+3]]:10: ERROR: Expected identifier after `.`.
// CHECK:STDERR: var x: {.(a) = 1};
// CHECK:STDERR: ^
var x: {.(a) = 1};
// CHECK:STDOUT: - filename: fail_dot_paren.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: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'IdentifierName', text: '(', has_error: yes},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntLiteral', text: '1'},
// 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: 'VariableDecl', text: ';', subtree_size: 10},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]