v2 / vlib / v / checker / tests / incorrect_smartcast3_err.vv
34 lines · 26 sloc · 434 bytes · 8225622da5d5a31fee4024476bc52eb433aaadf0
Raw
1module main
2
3import regex { RE, regex_opt }
4
5pub struct EmptyRegex {
6}
7
8type OurRegex = EmptyRegex | RE
9
10pub struct ListArgs {
11pub mut:
12 regex OurRegex
13}
14
15fn main() {
16 query := r'(c(pa)+z ?)+'
17 mut re := regex_opt(query) or { panic(err) }
18
19 item := 'sss'
20 mut la := ListArgs{
21 regex: re
22 }
23
24 mut r := la.regex
25 if r is RE {
26 println(r)
27 println(r.matches_string(item))
28 }
29
30 match r {
31 RE { r.matches_string(item) }
32 else {}
33 }
34}
35