@@ -560,7 +560,7 @@ fn (mut g Gen) call_expr(node ast.CallExpr) {
560
560
&& g.pref.gc_mode in [.boehm_full, .boehm_incr, .boehm_full_opt, .boehm_incr_opt]
561
561
gen_or := node.or_block.kind != .absent // && !g.is_autofree
562
562
is_gen_or_and_assign_rhs := gen_or && ! g.discard_or_result
563
- cur_line := if is_gen_or_and_assign_rhs || gen_keep_alive { // && !g.is_autofree {
563
+ mut cur_line := if is_gen_or_and_assign_rhs || gen_keep_alive { // && !g.is_autofree {
564
564
// `x := foo() or { ...}`
565
565
// cut everything that has been generated to prepend optional variable creation
566
566
line := g.go_before_stmt (0 )
@@ -577,6 +577,9 @@ fn (mut g Gen) call_expr(node ast.CallExpr) {
577
577
ret_typ = ret_typ.set_flag (.optional)
578
578
}
579
579
styp := g.typ (ret_typ)
580
+ if gen_or && ! is_gen_or_and_assign_rhs {
581
+ cur_line = g.go_before_stmt (0 )
582
+ }
580
583
g.write ('$styp $tmp_opt = ' )
581
584
}
582
585
if node.is_method && ! node.is_field {
@@ -594,19 +597,17 @@ fn (mut g Gen) call_expr(node ast.CallExpr) {
594
597
// if !g.is_autofree {
595
598
g.or_block (tmp_opt, node.or_block, node.return_type)
596
599
// }
597
- if is_gen_or_and_assign_rhs {
598
- unwrapped_typ := node.return_type.clear_flag (.optional)
599
- unwrapped_styp := g.typ (unwrapped_typ)
600
- if unwrapped_typ == ast.void_type {
601
- g.write ('\n $cur_line ' )
602
- } else if g.table.get_type_symbol (node.return_type).kind == .multi_return {
603
- g.write ('\n $cur_line $tmp_opt /*U*/' )
600
+ unwrapped_typ := node.return_type.clear_flag (.optional)
601
+ unwrapped_styp := g.typ (unwrapped_typ)
602
+ if unwrapped_typ == ast.void_type {
603
+ g.write ('\n $cur_line ' )
604
+ } else if g.table.get_type_symbol (node.return_type).kind == .multi_return {
605
+ g.write ('\n $cur_line $tmp_opt /*U*/' )
606
+ } else {
607
+ if ! g.inside_const {
608
+ g.write ('\n $cur_line (*($unwrapped_styp *)${tmp_opt} .data)' )
604
609
} else {
605
- if ! g.inside_const {
606
- g.write ('\n $cur_line (*($unwrapped_styp *)${tmp_opt} .data)' )
607
- } else {
608
- g.write ('\n $cur_line $tmp_opt ' )
609
- }
610
+ g.write ('\n $cur_line $tmp_opt ' )
610
611
}
611
612
}
612
613
} else if gen_keep_alive {
0 commit comments