1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: allow for const ( x = opt() ? )

This commit is contained in:
Delyan Angelov
2020-12-04 12:44:16 +02:00
parent d0a2992335
commit 52ccdd747f
3 changed files with 55 additions and 1 deletions

View File

@@ -0,0 +1,17 @@
import regex
const (
a_or_b = regex.regex_opt('a|b') ?
)
fn f(s string) bool {
mut re := a_or_b
start, _ := re.match_string(s)
return start != -1
}
fn test_const_regex_works() {
assert f('a') == true
assert f('b') == true
assert f('c') == false
}