fail_not_reachable_default.carbon 780 B

123456789101112131415161718192021222324252627
  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. package ExplorerTest api;
  7. choice Opt {
  8. None(),
  9. Some(i32)
  10. }
  11. fn A(a: Opt, b: Opt) -> i32 {
  12. match ((a, b)) {
  13. case (Opt.None(), Opt.None()) => { return 0; }
  14. case (Opt.Some(n: i32), _: auto) => { return n; }
  15. case (_: auto, Opt.Some(n: i32)) => { return n; }
  16. // CHECK:STDERR: COMPILATION ERROR: explorer/testdata/match/fail_not_reachable_default.carbon:[[@LINE+1]]: unreachable case: all values matched by this case are matched by earlier cases
  17. default => { return -1; }
  18. }
  19. return 0;
  20. }
  21. fn Main() -> i32 {
  22. return A(Opt.None(), Opt.Some(1));
  23. }