diff --git a/vlib/v/gen/c/str.v b/vlib/v/gen/c/str.v index f09a82edf3..eefdd5500c 100644 --- a/vlib/v/gen/c/str.v +++ b/vlib/v/gen/c/str.v @@ -85,7 +85,7 @@ fn (mut g Gen) gen_expr_to_string(expr ast.Expr, etype ast.Type) { } else if typ == ast.bool_type { g.expr(expr) g.write(' ? _SLIT("true") : _SLIT("false")') - } else if sym.kind == .none_ { + } else if sym.kind == .none_ || typ == ast.void_type.set_flag(.option) { g.write('_SLIT("")') } else if sym.kind == .enum_ { if expr !is ast.EnumVal { diff --git a/vlib/v/tests/option_void_fn_return_test.v b/vlib/v/tests/option_void_fn_return_test.v new file mode 100644 index 0000000000..5c354ac5e3 --- /dev/null +++ b/vlib/v/tests/option_void_fn_return_test.v @@ -0,0 +1,8 @@ +fn foo() ? { + return none +} + +fn test_main() { + println(foo()) // + assert true +}