fail_not_reachable.carbon 736 B

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