fail_not_reachable_default.carbon 855 B

1234567891011121314151617181920212223242526272829
  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. // RUN: %{not} %{explorer-run}
  7. // RUN: %{not} %{explorer-run-trace}
  8. package ExplorerTest api;
  9. choice Opt {
  10. None(),
  11. Some(i32)
  12. }
  13. fn A(a: Opt, b: Opt) -> i32 {
  14. match ((a, b)) {
  15. case (Opt.None(), Opt.None()) => { return 0; }
  16. case (Opt.Some(n: i32), _: auto) => { return n; }
  17. case (_: auto, Opt.Some(n: i32)) => { return n; }
  18. // 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
  19. default => { return -1; }
  20. }
  21. return 0;
  22. }
  23. fn Main() -> i32 {
  24. return A(Opt.None(), Opt.Some(1));
  25. }