diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 3b5b54abb7..44d3500d39 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -7332,7 +7332,7 @@ fn (mut g Gen) or_block(var_name string, or_block ast.OrExpr, return_type ast.Ty // the deferred statements are generated. g.write_defer_stmts() // Now that option types are distinct we need a cast here - if g.fn_decl.return_type == ast.void_type { + if g.fn_decl == unsafe { nil } || g.fn_decl.return_type == ast.void_type { g.writeln('\treturn;') } else { styp := g.styp(g.fn_decl.return_type) @@ -7360,7 +7360,7 @@ fn (mut g Gen) or_block(var_name string, or_block ast.OrExpr, return_type ast.Ty // the deferred statements are generated. g.write_defer_stmts() // Now that option types are distinct we need a cast here - if g.fn_decl.return_type == ast.void_type { + if g.fn_decl == unsafe { nil } || g.fn_decl.return_type == ast.void_type { g.writeln('\treturn;') } else { styp := g.styp(g.fn_decl.return_type).replace('*', '_ptr') diff --git a/vlib/v/tests/options/modules/mymod/mod.v b/vlib/v/tests/options/modules/mymod/mod.v new file mode 100644 index 0000000000..2b845ae565 --- /dev/null +++ b/vlib/v/tests/options/modules/mymod/mod.v @@ -0,0 +1,16 @@ +// mod.v + +module mymod + +import math.big + +pub struct BigintRange { +pub mut: + start big.Integer + end big.Integer +} + +pub const range = BigintRange{ + start: big.integer_from_string('338288524927261089654018896841347694592')! + end: big.integer_from_string('338620831926207318622244848606417780735')! +} diff --git a/vlib/v/tests/options/modules/mymod/mod_test.v b/vlib/v/tests/options/modules/mymod/mod_test.v new file mode 100644 index 0000000000..526f94deb3 --- /dev/null +++ b/vlib/v/tests/options/modules/mymod/mod_test.v @@ -0,0 +1,7 @@ +// mod_test.v + +module mymod + +fn test_dummy() { + assert range != BigintRange{} +}