fail_missing_name.carbon 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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/let/fail_missing_name.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/let/fail_missing_name.carbon
  10. // --- fail_runtime_binding.carbon
  11. // CHECK:STDERR: fail_runtime_binding.carbon:[[@LINE+4]]:5: error: expected name in binding pattern [ExpectedBindingPattern]
  12. // CHECK:STDERR: let : i32 = 4;
  13. // CHECK:STDERR: ^
  14. // CHECK:STDERR:
  15. let : i32 = 4;
  16. // --- fail_complietime_binding.carbon
  17. // CHECK:STDERR: fail_complietime_binding.carbon:[[@LINE+4]]:5: error: expected name in binding pattern [ExpectedBindingPattern]
  18. // CHECK:STDERR: let :! bool = true;
  19. // CHECK:STDERR: ^~
  20. // CHECK:STDERR:
  21. let :! bool = true;
  22. // CHECK:STDOUT: - filename: fail_runtime_binding.carbon
  23. // CHECK:STDOUT: parse_tree: [
  24. // CHECK:STDOUT: {kind: 'FileStart', text: ''},
  25. // CHECK:STDOUT: {kind: 'LetIntroducer', text: 'let'},
  26. // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: ':', has_error: yes},
  27. // CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
  28. // CHECK:STDOUT: {kind: 'LetBindingPattern', text: ':', has_error: yes, subtree_size: 3},
  29. // CHECK:STDOUT: {kind: 'LetInitializer', text: '='},
  30. // CHECK:STDOUT: {kind: 'IntLiteral', text: '4'},
  31. // CHECK:STDOUT: {kind: 'LetDecl', text: ';', subtree_size: 7},
  32. // CHECK:STDOUT: {kind: 'FileEnd', text: ''},
  33. // CHECK:STDOUT: ]
  34. // CHECK:STDOUT: - filename: fail_complietime_binding.carbon
  35. // CHECK:STDOUT: parse_tree: [
  36. // CHECK:STDOUT: {kind: 'FileStart', text: ''},
  37. // CHECK:STDOUT: {kind: 'LetIntroducer', text: 'let'},
  38. // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: ':!', has_error: yes},
  39. // CHECK:STDOUT: {kind: 'BoolTypeLiteral', text: 'bool'},
  40. // CHECK:STDOUT: {kind: 'CompileTimeBindingPattern', text: ':!', has_error: yes, subtree_size: 3},
  41. // CHECK:STDOUT: {kind: 'LetInitializer', text: '='},
  42. // CHECK:STDOUT: {kind: 'BoolLiteralTrue', text: 'true'},
  43. // CHECK:STDOUT: {kind: 'LetDecl', text: ';', subtree_size: 7},
  44. // CHECK:STDOUT: {kind: 'FileEnd', text: ''},
  45. // CHECK:STDOUT: ]