autofree: test `return x[0]` (optional)

pull/9617/head
Alexander Medvednikov 2021-04-06 17:28:07 +03:00
parent dbaa91810f
commit 1e2a92945c
1 changed files with 10 additions and 2 deletions

View File

@ -353,13 +353,21 @@ fn parse_header0(s string) ?string {
return error('missing colon in header')
}
words := s.split_nth(':', 2)
// x := words[0]
// return x
x := words[0]
return x
}
fn parse_header1(s string) ?string {
if !s.contains(':') {
return error('missing colon in header')
}
words := s.split_nth(':', 2)
return words[0]
}
fn advanced_optionals() {
s := parse_header0('foo:bar') or { return }
s2 := parse_header1('foo:bar') or { return }
}
fn main() {