fail_match_clause.carbon 542 B

12345678910111213141516171819202122232425
  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. // NOAUTOUPDATE
  6. package ExplorerTest api;
  7. fn Foo() -> i32;
  8. fn Main() -> i32 {
  9. var x : i32;
  10. match (Foo()) {
  11. case 0 => {
  12. return 2;
  13. }
  14. case 1 => {
  15. // CHECK:STDERR: COMPILATION ERROR: fail_match_clause.carbon:[[@LINE+1]]: use of uninitialized variable x
  16. return x;
  17. }
  18. default => {
  19. return 0;
  20. }
  21. }
  22. }