fail_missing_case_arrow.carbon 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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() -> i32 {
  7. match (3) {
  8. // CHECK:STDERR: fail_missing_case_arrow.carbon:[[@LINE+4]]:17: ERROR: Expected `=>` introducing statement block.
  9. // CHECK:STDERR: case x: i32 { return 2; }
  10. // CHECK:STDERR: ^
  11. // CHECK:STDERR:
  12. case x: i32 { return 2; }
  13. // CHECK:STDERR: fail_missing_case_arrow.carbon:[[@LINE+3]]:29: ERROR: Expected `=>` introducing statement block.
  14. // CHECK:STDERR: case x: i32 if (x == 3) { return 3; }
  15. // CHECK:STDERR: ^
  16. case x: i32 if (x == 3) { return 3; }
  17. }
  18. return 0;
  19. }
  20. // CHECK:STDOUT: - filename: fail_missing_case_arrow.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: 'IntTypeLiteral', text: 'i32'},
  28. // CHECK:STDOUT: {kind: 'ReturnType', text: '->', subtree_size: 2},
  29. // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 7},
  30. // CHECK:STDOUT: {kind: 'MatchIntroducer', text: 'match'},
  31. // CHECK:STDOUT: {kind: 'MatchConditionStart', text: '('},
  32. // CHECK:STDOUT: {kind: 'IntLiteral', text: '3'},
  33. // CHECK:STDOUT: {kind: 'MatchCondition', text: ')', subtree_size: 3},
  34. // CHECK:STDOUT: {kind: 'MatchStatementStart', text: '{', subtree_size: 5},
  35. // CHECK:STDOUT: {kind: 'MatchCaseIntroducer', text: 'case'},
  36. // CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
  37. // CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
  38. // CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3},
  39. // CHECK:STDOUT: {kind: 'MatchCaseEqualGreater', text: '{', has_error: yes},
  40. // CHECK:STDOUT: {kind: 'MatchCaseStart', text: '{', has_error: yes, subtree_size: 6},
  41. // CHECK:STDOUT: {kind: 'MatchCase', text: '{', has_error: yes, subtree_size: 7},
  42. // CHECK:STDOUT: {kind: 'MatchCaseIntroducer', text: 'case'},
  43. // CHECK:STDOUT: {kind: 'IdentifierName', text: 'x'},
  44. // CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
  45. // CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3},
  46. // CHECK:STDOUT: {kind: 'MatchCaseGuardIntroducer', text: 'if'},
  47. // CHECK:STDOUT: {kind: 'MatchCaseGuardStart', text: '('},
  48. // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'x'},
  49. // CHECK:STDOUT: {kind: 'IntLiteral', text: '3'},
  50. // CHECK:STDOUT: {kind: 'InfixOperatorEqualEqual', text: '==', subtree_size: 3},
  51. // CHECK:STDOUT: {kind: 'MatchCaseGuard', text: ')', subtree_size: 6},
  52. // CHECK:STDOUT: {kind: 'MatchCaseEqualGreater', text: '{', has_error: yes},
  53. // CHECK:STDOUT: {kind: 'MatchCaseStart', text: '{', has_error: yes, subtree_size: 12},
  54. // CHECK:STDOUT: {kind: 'MatchCase', text: '{', has_error: yes, subtree_size: 13},
  55. // CHECK:STDOUT: {kind: 'MatchStatement', text: '}', subtree_size: 26},
  56. // CHECK:STDOUT: {kind: 'ReturnStatementStart', text: 'return'},
  57. // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'},
  58. // CHECK:STDOUT: {kind: 'ReturnStatement', text: ';', subtree_size: 3},
  59. // CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 37},
  60. // CHECK:STDOUT: {kind: 'FileEnd', text: ''},
  61. // CHECK:STDOUT: ]