fail_top_level_if.carbon 2.1 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. fn F() {
  7. // CHECK:STDERR: fail_top_level_if.carbon:[[@LINE+11]]:6: ERROR: Expected `(` after `if`.
  8. // CHECK:STDERR: if true then 1 else 2;
  9. // CHECK:STDERR: ^~~~
  10. // CHECK:STDERR:
  11. // CHECK:STDERR: fail_top_level_if.carbon:[[@LINE+7]]:11: ERROR: Expected braced code block.
  12. // CHECK:STDERR: if true then 1 else 2;
  13. // CHECK:STDERR: ^~~~
  14. // CHECK:STDERR:
  15. // CHECK:STDERR: fail_top_level_if.carbon:[[@LINE+3]]:11: ERROR: Expected expression.
  16. // CHECK:STDERR: if true then 1 else 2;
  17. // CHECK:STDERR: ^~~~
  18. if true then 1 else 2;
  19. }
  20. // CHECK:STDOUT: - filename: fail_top_level_if.carbon
  21. // CHECK:STDOUT: parse_tree: [
  22. // CHECK:STDOUT: {kind: 'FileStart', text: ''},
  23. // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'},
  24. // CHECK:STDOUT: {kind: 'IdentifierName', text: 'F'},
  25. // CHECK:STDOUT: {kind: 'TuplePatternStart', text: '('},
  26. // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2},
  27. // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5},
  28. // CHECK:STDOUT: {kind: 'IfConditionStart', text: 'if', has_error: yes},
  29. // CHECK:STDOUT: {kind: 'BoolLiteralTrue', text: 'true'},
  30. // CHECK:STDOUT: {kind: 'IfCondition', text: 'if', has_error: yes, subtree_size: 3},
  31. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: 'then', has_error: yes},
  32. // CHECK:STDOUT: {kind: 'InvalidParse', text: 'then', has_error: yes},
  33. // CHECK:STDOUT: {kind: 'ExprStatement', text: ';', has_error: yes, subtree_size: 2},
  34. // CHECK:STDOUT: {kind: 'CodeBlock', text: 'then', has_error: yes, subtree_size: 4},
  35. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 8},
  36. // CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 14},
  37. // CHECK:STDOUT: {kind: 'FileEnd', text: ''},
  38. // CHECK:STDOUT: ]