@@ -2702,11 +2702,11 @@ fn (mut g Gen) write_sumtype_casting_fn(fun SumtypeCastingFn) {
2702
2702
g.auto_fn_definitions << sb.str ()
2703
2703
}
2704
2704
2705
- fn (mut g Gen) call_cfn_for_casting_expr (fname string , expr ast.Expr, exp_is_ptr bool , exp_styp string ,
2705
+ fn (mut g Gen) call_cfn_for_casting_expr (fname string , expr ast.Expr, exp ast.Type , exp_styp string ,
2706
2706
got_is_ptr bool , got_is_fn bool , got_styp string ) {
2707
2707
mut rparen_n := 1
2708
2708
is_comptime_variant := expr is ast.Ident && g.comptime.is_comptime_variant_var (expr)
2709
- if exp_is_ptr {
2709
+ if exp. is_ptr () {
2710
2710
g.write ('HEAP(${exp_styp} , ' )
2711
2711
rparen_n++
2712
2712
}
@@ -2744,7 +2744,10 @@ fn (mut g Gen) call_cfn_for_casting_expr(fname string, expr ast.Expr, exp_is_ptr
2744
2744
ast.void_type)
2745
2745
g.write (g.type_default (ctyp))
2746
2746
} else {
2747
+ old_left_is_opt := g.left_is_opt
2748
+ g.left_is_opt = ! exp.has_flag (.option)
2747
2749
g.expr (expr)
2750
+ g.left_is_opt = old_left_is_opt
2748
2751
}
2749
2752
g.write (')' .repeat (rparen_n))
2750
2753
}
@@ -2838,8 +2841,8 @@ fn (mut g Gen) expr_with_cast(expr ast.Expr, got_type_raw ast.Type, expected_typ
2838
2841
if exp_sym.info.is_generic {
2839
2842
fname = g.generic_fn_name (exp_sym.info.concrete_types, fname)
2840
2843
}
2841
- g.call_cfn_for_casting_expr (fname, expr, expected_is_ptr , exp_styp, true ,
2842
- false , got_styp)
2844
+ g.call_cfn_for_casting_expr (fname, expr, expected_type , exp_styp, true , false ,
2845
+ got_styp)
2843
2846
g.inside_cast_in_heap--
2844
2847
} else {
2845
2848
got_styp := g.cc_type (got_type, true )
@@ -2865,7 +2868,7 @@ fn (mut g Gen) expr_with_cast(expr ast.Expr, got_type_raw ast.Type, expected_typ
2865
2868
return
2866
2869
}
2867
2870
}
2868
- g.call_cfn_for_casting_expr (fname, expr, expected_is_ptr , exp_styp, got_is_ptr,
2871
+ g.call_cfn_for_casting_expr (fname, expr, expected_type , exp_styp, got_is_ptr,
2869
2872
false , got_styp)
2870
2873
}
2871
2874
return
@@ -2930,7 +2933,7 @@ fn (mut g Gen) expr_with_cast(expr ast.Expr, got_type_raw ast.Type, expected_typ
2930
2933
g.write ('${fname} (&${tmp_var} )' )
2931
2934
return
2932
2935
} else {
2933
- g.call_cfn_for_casting_expr (fname, expr, expected_is_ptr , unwrapped_exp_sym.cname,
2936
+ g.call_cfn_for_casting_expr (fname, expr, expected_type , unwrapped_exp_sym.cname,
2934
2937
got_is_ptr, got_is_fn, got_styp)
2935
2938
}
2936
2939
}
0 commit comments