Skip to content

Commit b576181

Browse files
committed
cgen: fix const x := opt() or {} side effect interference when the consts are in different files in the same module too
1 parent e275220 commit b576181

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

vlib/v/gen/c/cgen.v

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5833,7 +5833,9 @@ fn (mut g Gen) const_decl_init_later(mod string, name string, expr ast.Expr, typ
58335833
}
58345834
} else {
58355835
if unwrap_option {
5836+
g.init.writeln('{')
58365837
g.init.writeln(g.expr_string_surround('\t$cname = *($styp*)', expr, '.data;'))
5838+
g.init.writeln('}')
58375839
} else {
58385840
g.init.writeln(g.expr_string_surround('\t$cname = ', expr, ';'))
58395841
}

0 commit comments

Comments
 (0)