fmt: fix ?void format error, add _keep.vv test

pull/5204/head
yuyi 2020-06-03 23:45:40 +08:00 committed by GitHub
parent ffafeac0f8
commit 962bbf1c60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -0,0 +1,9 @@
fn tt() ? {
return error('error')
}
fn main() {
tt() or {
panic('$err')
}
}

View File

@ -707,8 +707,12 @@ pub fn (table &Table) type_to_str(t Type) string {
res = strings.repeat(`&`, nr_muls) + res res = strings.repeat(`&`, nr_muls) + res
} }
if t.flag_is(.optional) { if t.flag_is(.optional) {
if sym.kind == .void {
res = '?'
} else {
res = '?' + res res = '?' + res
} }
}
/* /*
if res.starts_with(cur_mod +'.') { if res.starts_with(cur_mod +'.') {
res = res[cur_mod.len+1.. ] res = res[cur_mod.len+1.. ]