fail_errors.carbon 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. fn F() {
  7. // CHECK:STDERR: fail_errors.carbon:[[@LINE+3]]:6: ERROR: Expected `(` after `if`.
  8. // CHECK:STDERR: if a {}
  9. // CHECK:STDERR: ^
  10. if a {}
  11. // CHECK:STDERR: fail_errors.carbon:[[@LINE+3]]:7: ERROR: Expected expression.
  12. // CHECK:STDERR: if () {}
  13. // CHECK:STDERR: ^
  14. if () {}
  15. // CHECK:STDERR: fail_errors.carbon:[[@LINE+3]]:9: ERROR: Unexpected tokens before `)`.
  16. // CHECK:STDERR: if (b c) {}
  17. // CHECK:STDERR: ^
  18. if (b c) {}
  19. if (d)
  20. // CHECK:STDERR: fail_errors.carbon:[[@LINE+6]]:1: ERROR: Expected braced code block.
  21. // CHECK:STDERR: }
  22. // CHECK:STDERR: ^
  23. // CHECK:STDERR: fail_errors.carbon:[[@LINE+3]]:1: ERROR: Expected expression.
  24. // CHECK:STDERR: }
  25. // CHECK:STDERR: ^
  26. }
  27. // CHECK:STDOUT: - filename: fail_errors.carbon
  28. // CHECK:STDOUT: parse_tree: [
  29. // CHECK:STDOUT: {kind: 'FileStart', text: ''},
  30. // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'},
  31. // CHECK:STDOUT: {kind: 'IdentifierName', text: 'F'},
  32. // CHECK:STDOUT: {kind: 'TuplePatternStart', text: '('},
  33. // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2},
  34. // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5},
  35. // CHECK:STDOUT: {kind: 'IfConditionStart', text: 'if', has_error: yes},
  36. // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'a'},
  37. // CHECK:STDOUT: {kind: 'IfCondition', text: 'if', has_error: yes, subtree_size: 3},
  38. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'},
  39. // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 2},
  40. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 6},
  41. // CHECK:STDOUT: {kind: 'IfConditionStart', text: '('},
  42. // CHECK:STDOUT: {kind: 'InvalidParse', text: ')', has_error: yes},
  43. // CHECK:STDOUT: {kind: 'IfCondition', text: ')', has_error: yes, subtree_size: 3},
  44. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'},
  45. // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 2},
  46. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 6},
  47. // CHECK:STDOUT: {kind: 'IfConditionStart', text: '('},
  48. // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'b'},
  49. // CHECK:STDOUT: {kind: 'IfCondition', text: ')', has_error: yes, subtree_size: 3},
  50. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'},
  51. // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 2},
  52. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 6},
  53. // CHECK:STDOUT: {kind: 'IfConditionStart', text: '('},
  54. // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'd'},
  55. // CHECK:STDOUT: {kind: 'IfCondition', text: ')', subtree_size: 3},
  56. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '}', has_error: yes},
  57. // CHECK:STDOUT: {kind: 'InvalidParse', text: '}', has_error: yes},
  58. // CHECK:STDOUT: {kind: 'ExprStatement', text: ')', has_error: yes, subtree_size: 2},
  59. // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', has_error: yes, subtree_size: 4},
  60. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 8},
  61. // CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 32},
  62. // CHECK:STDOUT: {kind: 'FileEnd', text: ''},
  63. // CHECK:STDOUT: ]