fail_exhaustive_exponential_series_t.carbon 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. // This is T9 from http://moscova.inria.fr/~maranget/papers/warn/warn014.html
  16. // Note, this match is exhaustive, but it exceeds our depth limit.
  17. match ((F(), F(), F(), F(), F(), F(), F(), F(), F())) {
  18. case (AB.A(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A()) => { return 0; }
  19. case (AB.B(), AB.B(), AB.B(), AB.B(), AB.B(), AB.B(), AB.B(), AB.B(), AB.B()) => { return 1; }
  20. case (_: AB, AB.A(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A()) => { return 2; }
  21. case (_: AB, AB.B(), AB.B(), AB.B(), AB.B(), AB.B(), AB.B(), AB.B(), AB.B()) => { return 3; }
  22. case (_: AB, _: AB, AB.A(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A()) => { return 4; }
  23. case (_: AB, _: AB, AB.B(), AB.B(), AB.B(), AB.B(), AB.B(), AB.B(), AB.B()) => { return 5; }
  24. case (_: AB, _: AB, _: AB, AB.A(), AB.A(), AB.A(), AB.A(), AB.A(), AB.A()) => { return 6; }
  25. case (_: AB, _: AB, _: AB, AB.B(), AB.B(), AB.B(), AB.B(), AB.B(), AB.B()) => { return 7; }
  26. case (_: AB, _: AB, _: AB, _: AB, AB.A(), AB.A(), AB.A(), AB.A(), AB.A()) => { return 8; }
  27. case (_: AB, _: AB, _: AB, _: AB, AB.B(), AB.B(), AB.B(), AB.B(), AB.B()) => { return 9; }
  28. case (_: AB, _: AB, _: AB, _: AB, _: AB, AB.A(), AB.A(), AB.A(), AB.A()) => { return 10; }
  29. case (_: AB, _: AB, _: AB, _: AB, _: AB, AB.B(), AB.B(), AB.B(), AB.B()) => { return 11; }
  30. case (_: AB, _: AB, _: AB, _: AB, _: AB, _: AB, AB.A(), AB.A(), AB.A()) => { return 12; }
  31. case (_: AB, _: AB, _: AB, _: AB, _: AB, _: AB, AB.B(), AB.B(), AB.B()) => { return 13; }
  32. case (_: AB, _: AB, _: AB, _: AB, _: AB, _: AB, _: AB, AB.A(), AB.A()) => { return 14; }
  33. case (_: AB, _: AB, _: AB, _: AB, _: AB, _: AB, _: AB, AB.B(), AB.B()) => { return 15; }
  34. case (_: AB, _: AB, _: AB, _: AB, _: AB, _: AB, _: AB, _: AB, AB.A()) => { return 16; }
  35. case (_: AB, _: AB, _: AB, _: AB, _: AB, _: AB, _: AB, _: AB, AB.B()) => { return 17; }
  36. }
  37. // CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/match/fail_exhaustive_exponential_series_t.carbon:[[@LINE+1]]: non-exhaustive match may allow control-flow to reach the end of a function that provides a `->` return type
  38. }