fail_not_reachable.carbon 833 B

12345678910111213141516171819202122232425262728
  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.Some(n: i32), _: auto) => { return n; }
  16. case (_: auto, Opt.Some(n: i32)) => { return n; }
  17. // CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/match/fail_not_reachable.carbon:[[@LINE+1]]: unreachable case: all values matched by this case are matched by earlier cases
  18. case (Opt.Some(m: i32), Opt.Some(n: i32)) => { return m + n; }
  19. }
  20. return 0;
  21. }
  22. fn Main() -> i32 {
  23. return A(Opt.None(), Opt.Some(1));
  24. }