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

pull/12546/head
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
1 changed files with 2 additions and 0 deletions

View File

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