File: exhaustive_switch_invocation_threshold.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (51 lines) | stat: -rw-r--r-- 1,330 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Ensure that -switch-checking-invocation-threshold= frontend option works,
// stopping the check, producing the correct diagnostic, and not producing the
// diagnostic for a completed check.
//
// RUN: %empty-directory(%t)
//
// RUN: not %target-swift-frontend -typecheck %s -switch-checking-invocation-threshold=1 2>%t/unproven.txt
// RUN: %FileCheck %s --check-prefix UNABLE-TO-CHECK <%t/unproven.txt
// RUN: not %FileCheck %s --check-prefix MUST-BE-EXHAUSTIVE <%t/unproven.txt
//
// RUN: not %target-swift-frontend -typecheck %s  2>%t/disproved.txt
// RUN: %FileCheck %s --check-prefix MUST-BE-EXHAUSTIVE <%t/disproved.txt
// RUN: not %FileCheck %s --check-prefix UNABLE-TO-CHECK <%t/disproved.txt
//
// UNABLE-TO-CHECK: error: the compiler is unable to check that this switch is exhaustive in reasonable time
// MUST-BE-EXHAUSTIVE: error: switch must be exhaustive


enum A {
  case a1, a2, a3, a4, a5
}
enum B {
  case b1, b2, b3, b4
}

func f(a: A, b: B) {
  switch (a, b) {
    case
//    (.a1, .b1),
    (.a2, .b1),
    (.a3, .b1),
    (.a4, .b1),
    (.a5, .b1),
    (.a1, .b2),
    (.a2, .b2),
    (.a3, .b2),
    (.a4, .b2),
    (.a5, .b2),
    (.a1, .b3),
    (.a2, .b3),
    (.a3, .b3),
    (.a4, .b3),
    (.a5, .b3),
    (.a1, .b4),
    (.a2, .b4),
    (.a3, .b4),
    (.a4, .b4),
    (.a5, .b4):
    break
  }
}