| 
1 | 1 | // RUN: %target-typecheck-verify-swift -enable-experimental-string-processing  | 
2 | 2 | // REQUIRES: swift_in_compiler  | 
3 | 3 | 
 
  | 
4 |  | -let r0 = '/./'  | 
 | 4 | +let r0 = #/./#  | 
5 | 5 | let _: Regex<Substring> = r0  | 
6 | 6 | 
 
  | 
7 | 7 | func takesRegex<Match>(_: Regex<Match>) {}  | 
8 |  | -takesRegex('//') // okay  | 
 | 8 | +takesRegex(#//#) // okay  | 
9 | 9 | 
 
  | 
10 |  | -let r1 = '/.(.)/'  | 
 | 10 | +let r1 = #/.(.)/#  | 
11 | 11 | // Note: We test its type with a separate statement so that we know the type  | 
12 | 12 | // checker inferred the regex's type independently without contextual types.  | 
13 | 13 | let _: Regex<(Substring, Substring)>.Type = type(of: r1)  | 
14 | 14 | 
 
  | 
15 | 15 | struct S {}  | 
16 | 16 | // expected-error @+2 {{cannot assign value of type 'Regex<(Substring, Substring)>' to type 'Regex<S>'}}  | 
17 | 17 | // expected-note @+1 {{arguments to generic parameter 'Match' ('(Substring, Substring)' and 'S') are expected to be equal}}  | 
18 |  | -let r2: Regex<S> = '/.(.)/'  | 
 | 18 | +let r2: Regex<S> = #/.(.)/#  | 
19 | 19 | 
 
  | 
20 |  | -let r3 = '/(.)(.)/'  | 
 | 20 | +let r3 = #/(.)(.)/#  | 
21 | 21 | let _: Regex<(Substring, Substring, Substring)>.Type = type(of: r3)  | 
22 | 22 | 
 
  | 
23 |  | -let r4 = '/(?<label>.)(.)/'  | 
 | 23 | +let r4 = #/(?<label>.)(.)/#  | 
24 | 24 | let _: Regex<(Substring, label: Substring, Substring)>.Type = type(of: r4)  | 
25 | 25 | 
 
  | 
26 |  | -let r5 = '/(.(.(.)))/'  | 
 | 26 | +let r5 = #/(.(.(.)))/#  | 
27 | 27 | let _: Regex<(Substring, Substring, Substring, Substring)>.Type = type(of: r5)  | 
28 | 28 | 
 
  | 
29 |  | -let r6 = '/(?'we'.(?'are'.(?'regex'.)+)?)/'  | 
30 |  | -let _: Regex<(Substring, we: Substring, are: Substring?, regex: [Substring]?)>.Type = type(of: r6)  | 
 | 29 | +let r6 = #/(?'we'.(?'are'.(?'regex'.)+)?)/#  | 
 | 30 | +let _: Regex<(Substring, we: Substring, are: Substring?, regex: Substring?)>.Type = type(of: r6)  | 
31 | 31 | 
 
  | 
32 |  | -let r7 = '/(?:(?:(.(.(.)*)?))*?)?/'  | 
 | 32 | +let r7 = #/(?:(?:(.(.(.)*)?))*?)?/#  | 
33 | 33 | //               ^ 1  | 
34 | 34 | //                 ^ 2  | 
35 | 35 | //                   ^ 3  | 
36 |  | -let _: Regex<(Substring, [Substring]?, [Substring?]?, [[Substring]?]?)>.Type = type(of: r7)  | 
 | 36 | +let _: Regex<(Substring, Substring??, Substring???, Substring????)>.Type = type(of: r7)  | 
37 | 37 | 
 
  | 
38 |  | -let r8 = '/well(?<theres_no_single_element_tuple_what_can_we>do)/'  | 
 | 38 | +let r8 = #/well(?<theres_no_single_element_tuple_what_can_we>do)/#  | 
39 | 39 | let _: Regex<(Substring, theres_no_single_element_tuple_what_can_we: Substring)>.Type = type(of: r8)  | 
40 | 40 | 
 
  | 
41 |  | -let r9 = '/(a)|(b)|(c)|d/'  | 
 | 41 | +let r9 = #/(a)|(b)|(c)|d/#  | 
42 | 42 | let _: Regex<(Substring, Substring?, Substring?, Substring?)>.Type = type(of: r9)  | 
43 | 43 | 
 
  | 
44 |  | -let r10 = '/(a)|b/'  | 
 | 44 | +let r10 = #/(a)|b/#  | 
45 | 45 | let _: Regex<(Substring, Substring?)>.Type = type(of: r10)  | 
46 | 46 | 
 
  | 
47 |  | -let r11 = '/()()()()()()()()/'  | 
 | 47 | +let r11 = #/()()()()()()()()/#  | 
48 | 48 | let _: Regex<(Substring, Substring, Substring, Substring, Substring, Substring, Substring, Substring, Substring)>.Type = type(of: r11)  | 
0 commit comments