diff --git a/vlib/v/fmt/tests/void_optional_keep.vv b/vlib/v/fmt/tests/void_optional_keep.vv new file mode 100644 index 0000000000..32cb28ea76 --- /dev/null +++ b/vlib/v/fmt/tests/void_optional_keep.vv @@ -0,0 +1,9 @@ +fn tt() ? { + return error('error') +} + +fn main() { + tt() or { + panic('$err') + } +} diff --git a/vlib/v/table/atypes.v b/vlib/v/table/atypes.v index 2debd28297..7d350791c1 100644 --- a/vlib/v/table/atypes.v +++ b/vlib/v/table/atypes.v @@ -707,7 +707,11 @@ pub fn (table &Table) type_to_str(t Type) string { res = strings.repeat(`&`, nr_muls) + res } if t.flag_is(.optional) { - res = '?' + res + if sym.kind == .void { + res = '?' + } else { + res = '?' + res + } } /* if res.starts_with(cur_mod +'.') {