diff options
| author | Vexu <git@vexu.eu> | 2020-05-12 15:20:03 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-12 15:20:03 +0300 |
| commit | 29b3be4f2f30f756ef0317f79c349f5565b04d19 (patch) | |
| tree | 1cf04ccfb8ce0b0fb2e2b68686abe452c0077fda /src/ir.cpp | |
| parent | 7456389ef3c29e37d5d9bc7f8365db3217b3f60e (diff) | |
| parent | 0847b47bf83c699d27c903e51b20f863d47c5790 (diff) | |
| download | zig-29b3be4f2f30f756ef0317f79c349f5565b04d19.tar.gz zig-29b3be4f2f30f756ef0317f79c349f5565b04d19.zip | |
Merge pull request #5319 from Vexu/float-fix
Fix intToFloat on comptime_floats
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index b5c4212ca5..6bd4e9b805 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -12760,9 +12760,7 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInst *source_instr, const_val->type = new_type; break; case CastOpIntToFloat: - { - assert(new_type->id == ZigTypeIdFloat); - + if (new_type->id == ZigTypeIdFloat) { BigFloat bigfloat; bigfloat_init_bigint(&bigfloat, &other_val->data.x_bigint); switch (new_type->data.floating.bit_count) { @@ -12783,9 +12781,13 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInst *source_instr, default: zig_unreachable(); } - const_val->special = ConstValSpecialStatic; - break; + } else if (new_type->id == ZigTypeIdComptimeFloat) { + bigfloat_init_bigint(&const_val->data.x_bigfloat, &other_val->data.x_bigint); + } else { + zig_unreachable(); } + const_val->special = ConstValSpecialStatic; + break; case CastOpFloatToInt: float_init_bigint(&const_val->data.x_bigint, other_val); if (new_type->id == ZigTypeIdInt) { |
