fail_period_string_colon.carbon 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/struct/fail_period_string_colon.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_period_string_colon.carbon
  10. // CHECK:STDERR: fail_period_string_colon.carbon:[[@LINE+4]]:10: error: expected identifier after `.` [ExpectedIdentifierAfterPeriodOrArrow]
  11. // CHECK:STDERR: var x: {."hello": i32, .y: i32} = {};
  12. // CHECK:STDERR: ^~~~~~~
  13. // CHECK:STDERR:
  14. var x: {."hello": i32, .y: i32} = {};
  15. // CHECK:STDOUT: - filename: fail_period_string_colon.carbon
  16. // CHECK:STDOUT: parse_tree: [
  17. // CHECK:STDOUT: {kind: 'FileStart', text: ''},
  18. // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
  19. // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeSignature', text: 'x'},
  20. // CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'},
  21. // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeSignature', text: '"hello"', has_error: yes},
  22. // CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
  23. // CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
  24. // CHECK:STDOUT: {kind: 'InvalidParse', text: ':', has_error: yes},
  25. // CHECK:STDOUT: {kind: 'StructTypeLiteralComma', text: ','},
  26. // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeSignature', text: 'y'},
  27. // CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
  28. // CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
  29. // CHECK:STDOUT: {kind: 'StructTypeLiteralField', text: ':', subtree_size: 4},
  30. // CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', has_error: yes, subtree_size: 11},
  31. // CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 13},
  32. // CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 14},
  33. // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
  34. // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'},
  35. // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
  36. // CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 19},
  37. // CHECK:STDOUT: {kind: 'FileEnd', text: ''},
  38. // CHECK:STDOUT: ]