| ... | ... | @@ -3783,7 +3783,19 @@ static TypeTableEntry *analyze_cast_expr(CodeGen *g, ImportTableEntry *import, B |
| 3783 | 3783 | actual_type->id == TypeTableEntryIdNumLitInt) |
| 3784 | 3784 | { |
| 3785 | 3785 | if (num_lit_fits_in_other_type(g, expr_node, wanted_type)) { |
| 3786 | | node->data.fn_call_expr.cast_op = CastOpNoop; |
| 3786 | if ((actual_type->id == TypeTableEntryIdNumLitFloat && |
| 3787 | wanted_type->id == TypeTableEntryIdFloat) || |
| 3788 | (actual_type->id == TypeTableEntryIdNumLitInt && |
| 3789 | wanted_type->id == TypeTableEntryIdInt)) |
| 3790 | { |
| 3791 | node->data.fn_call_expr.cast_op = CastOpNoop; |
| 3792 | } else if (wanted_type->id == TypeTableEntryIdInt) { |
| 3793 | node->data.fn_call_expr.cast_op = CastOpFloatToInt; |
| 3794 | } else if (wanted_type->id == TypeTableEntryIdFloat) { |
| 3795 | node->data.fn_call_expr.cast_op = CastOpIntToFloat; |
| 3796 | } else { |
| 3797 | zig_unreachable(); |
| 3798 | } |
| 3787 | 3799 | eval_const_expr_implicit_cast(g, node, expr_node); |
| 3788 | 3800 | return wanted_type; |
| 3789 | 3801 | } else { |