1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: fix const x := opt() or {} side effect interference when the consts are in different files in the same module too

This commit is contained in:
Delyan Angelov 2021-11-19 19:02:33 +02:00
parent e275220f05
commit b576181a66
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -5833,7 +5833,9 @@ fn (mut g Gen) const_decl_init_later(mod string, name string, expr ast.Expr, typ
} }
} else { } else {
if unwrap_option { if unwrap_option {
g.init.writeln('{')
g.init.writeln(g.expr_string_surround('\t$cname = *($styp*)', expr, '.data;')) g.init.writeln(g.expr_string_surround('\t$cname = *($styp*)', expr, '.data;'))
g.init.writeln('}')
} else { } else {
g.init.writeln(g.expr_string_surround('\t$cname = ', expr, ';')) g.init.writeln(g.expr_string_surround('\t$cname = ', expr, ';'))
} }