-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathforward-slash-regex-skipping.swift
127 lines (110 loc) · 2.49 KB
/
forward-slash-regex-skipping.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -disable-availability-checking -experimental-skip-all-function-bodies
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -disable-availability-checking -experimental-skip-non-inlinable-function-bodies-without-types
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -disable-availability-checking -experimental-skip-non-inlinable-function-bodies
// REQUIRES: swift_swift_parser
// Make sure we properly handle `/.../` regex literals in skipped function
// bodies. Currently we detect them and avoid skipping, but in the future we
// ought to be able to skip over them.
prefix operator ^^
prefix func ^^ <T>(_ x: T) -> T { x }
struct A {
static let r = /test":"(.*?)"/
}
struct B {
static let r = /x*/
}
struct C {
func foo() {
let r = /x*/
}
}
struct D {
func foo() {
func bar() {
let r = /x}}*/
}
}
}
func a() { _ = /abc}}*/ }
func b() { _ = /\// }
func c() { _ = /\\/ }
func d() { _ = ^^/x}}*/ }
func e() { _ = (^^/x}}*/) }
func f() { _ = ^^/^x}}*/ }
func g() { _ = "\(/x}}*/)" }
func h() { _ = "\(^^/x}}*/)" }
func i() {
func foo<T>(_ x: T, y: T) {}
foo(/}}*/, y: /"/)
}
func j() {
_ = {
0
/x}}}/
2
}
}
func k() {
_ = 2
/ 1 / .bitWidth
}
func l() {
_ = 2
/x}*/ .self
}
func m() {
_ = 2
/ 1 /
.bitWidth
}
func n() {
_ = 2
/x}/
.bitWidth
}
func o() {
_ = /x// comment
}
func p() {
_ = /x // comment
}
func q() {
_ = /x/*comment*/
}
func r() { _ = /[(0)]/ }
func s() { _ = /(x)/ }
func t() { _ = /[)]/ }
func u() { _ = /[a\])]/ }
func v() { _ = /([)])/ }
func w() { _ = /]]][)]/ }
func x() { _ = /,/ }
func y() { _ = /}/ }
func z() { _ = /]/ }
func a1() { _ = /:/ }
func a2() { _ = /;/ }
func a3() { _ = /)/ }
func a4() { _ = / / } // expected-error {{regex literal may not start with space; add backslash to escape}}
func a5() { _ = /\ / }
prefix operator /
prefix func / <T> (_ x: T) -> T { x }
enum E {
case e
func foo<T>(_ x: T) {}
}
func a7() { _ = /\/}/ }
// Make sure we don't emit errors for these.
func err1() { _ = /0xG/ }
func err2() { _ = /0oG/ }
func err3() { _ = /"/ }
func err4() { _ = /'/ }
func err5() { _ = /<#placeholder#>/ }
func err6() { _ = ^^/0xG/ }
func err7() { _ = ^^/0oG/ }
func err8() { _ = ^^/"/ }
func err9() { _ = ^^/'/ }
func err10() { _ = ^^/<#placeholder#>/ }
func err11() { _ = (^^/0xG/) }
func err12() { _ = (^^/0oG/) }
func err13() { _ = (^^/"/) }
func err14() { _ = (^^/'/) }
func err15() { _ = (^^/<#placeholder#>/) }