diff --git a/vlib/v/parser/parse_type.v b/vlib/v/parser/parse_type.v index 6ad3c961cc..44e968e130 100644 --- a/vlib/v/parser/parse_type.v +++ b/vlib/v/parser/parse_type.v @@ -136,7 +136,7 @@ pub fn (mut p Parser) parse_type() table.Type { if p.tok.kind != .lcbr { pos := p.tok.position() typ = p.parse_any_type(language, nr_muls > 0) - if typ == table.void_type { + if typ == table.void_type && is_optional { p.error_with_pos('use `?` instead of `?void`', pos) } } diff --git a/vlib/v/tests/inout/c_fn_can_return_void_type.out b/vlib/v/tests/inout/c_fn_can_return_void_type.out new file mode 100644 index 0000000000..9766475a41 --- /dev/null +++ b/vlib/v/tests/inout/c_fn_can_return_void_type.out @@ -0,0 +1 @@ +ok diff --git a/vlib/v/tests/inout/c_fn_can_return_void_type.vv b/vlib/v/tests/inout/c_fn_can_return_void_type.vv new file mode 100644 index 0000000000..f10bea8f42 --- /dev/null +++ b/vlib/v/tests/inout/c_fn_can_return_void_type.vv @@ -0,0 +1,4 @@ +fn C.some_c_function(int) void +fn main() { + println('ok') +}