fail_exhaustive_exponential_9x.carbon 1.7 KB

123456789101112131415161718192021222324252627282930313233
  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 AB {
  10. A(),
  11. B()
  12. }
  13. fn F() -> AB { return AB.A(); }
  14. fn Main() -> i32 {
  15. // Note, this match is exhaustive, but it exceeds our depth limit.
  16. match ((F(), F(), F(), F(), F(), F(), F(), F(), F())) {
  17. case (AB.A(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A()) => { return 0; }
  18. case (AB.B(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A()) => { return 1; }
  19. case (_: AB, AB.B(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A()) => { return 2; }
  20. case (_: AB, _: AB, AB.B(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A()) => { return 3; }
  21. case (_: AB, _: AB, _: AB, AB.B(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A()) => { return 4; }
  22. case (_: AB, _: AB, _: AB, _: AB, AB.B(), AB.A(), AB.A(), AB.A(), AB.A()) => { return 5; }
  23. case (_: AB, _: AB, _: AB, _: AB, _: AB, AB.B(), AB.A(), AB.A(), AB.A()) => { return 6; }
  24. case (_: AB, _: AB, _: AB, _: AB, _: AB, _: AB, AB.B(), AB.A(), AB.A()) => { return 7; }
  25. case (_: AB, _: AB, _: AB, _: AB, _: AB, _: AB, _: AB, AB.B(), AB.A()) => { return 8; }
  26. case (_: AB, _: AB, _: AB, _: AB, _: AB, _: AB, _: AB, _: AB, AB.B()) => { return 9; }
  27. }
  28. // CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/match/fail_exhaustive_exponential_9x.carbon:[[@LINE+1]]: non-exhaustive match may allow control-flow to reach the end of a function that provides a `->` return type
  29. }