fail_exhaustive_int.carbon 558 B

12345678910111213141516171819
  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. fn A(n: i32) -> i32 {
  8. match (n) {
  9. case 1 => { return 1; }
  10. case 2 => { return 2; }
  11. }
  12. // CHECK:STDERR: COMPILATION ERROR: fail_exhaustive_int.carbon:[[@LINE+1]]: non-exhaustive match may allow control-flow to reach the end of a function that provides a `->` return type
  13. }
  14. fn Main() -> i32 {
  15. return A(0);
  16. }