-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathcatch_let.swift
55 lines (48 loc) · 1.21 KB
/
catch_let.swift
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
52
53
54
55
// RUN: %target-swift-frontend %s -emit-ir -g -o - | %FileCheck %s
enum MyError : Error {
case Yikes
}
func throwing() throws -> () {
throw MyError.Yikes
}
func use<T>(_ t: T) {}
// CHECK-LABEL: define {{.*}}explicitBinding{{.*}}
public func explicitBinding() {
do {
try throwing()
}
catch let error {
// CHECK: #dbg_declare(ptr %{{.*}}, ![[EXPLICIT_ERROR:[0-9]+]],
use(error)
}
}
explicitBinding()
// CHECK-LABEL: define {{.*}}implicitBinding{{.*}}
public func implicitBinding() {
do {
try throwing()
}
catch {
// CHECK: #dbg_declare(ptr %{{.*}}, ![[IMPLICIT_ERROR:[0-9]+]],
use(error)
}
}
implicitBinding()
// CHECK-LABEL: define {{.*}}multiBinding{{.*}}
public func multiBinding() {
do {
try throwing()
}
catch let error as MyError, let error as MyError {
// CHECK: #dbg_declare(ptr %{{.*}}, ![[MULTI_BINDING_ERROR:[0-9]+]],
// CHECK-NOT: #dbg_declare(ptr %{{.*}}
// CHECK: define {{.*}}MyError{{.*}}
use(error)
} catch {
use(error)
}
}
multiBinding()
// CHECK: ![[EXPLICIT_ERROR]] = !DILocalVariable(name: "error"
// CHECK: ![[IMPLICIT_ERROR]] = !DILocalVariable(name: "error"
// CHECK: ![[MULTI_BINDING_ERROR]] = !DILocalVariable(name: "error"