| ... | @@ -3864,10 +3864,15 @@ fn analyzeArithmetic( | ... | @@ -3864,10 +3864,15 @@ fn analyzeArithmetic( |
| 3864 | // incase rhs is 0, simply return lhs without doing any calculations | 3864 | // incase rhs is 0, simply return lhs without doing any calculations |
| 3865 | // TODO Once division is implemented we should throw an error when dividing by 0. | 3865 | // TODO Once division is implemented we should throw an error when dividing by 0. |
| 3866 | if (rhs_val.compareWithZero(.eq)) { | 3866 | if (rhs_val.compareWithZero(.eq)) { |
| 3867 | return sema.mod.constInst(sema.arena, src, .{ | 3867 | switch (zir_tag) { |
| 3868 | .ty = scalar_type, | 3868 | .add, .addwrap, .sub, .subwrap => { |
| 3869 | .val = lhs_val, | 3869 | return sema.mod.constInst(sema.arena, src, .{ |
| 3870 | }); | 3870 | .ty = scalar_type, |
| | 3871 | .val = lhs_val, |
| | 3872 | }); |
| | 3873 | }, |
| | 3874 | else => {}, |
| | 3875 | } |
| 3871 | } | 3876 | } |
| 3872 | | 3877 | |
| 3873 | const value = switch (zir_tag) { | 3878 | const value = switch (zir_tag) { |