authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-07-09 23:24:21-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-07-09 23:24:21-07:00
log02619edf413cd3b8b01a6a3514ecd257d7c08b6e
treeb27dffca9c3c26ef8cb33776dfbdf1941e7f6e55
parent2e1bdd0d14f490a80bbed3ee0e0479a908715d33

Revert "use correct cast function when doing `@floatCast` at comptime"

This reverts commit 2e1bdd0d14f490a80bbed3ee0e0479a908715d33. Test failures

2 files changed, 1 insertions(+), 14 deletions(-)

src/ir.cpp+1-1
...@@ -26718,7 +26718,7 @@ static IrInstGen *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstSrcFlo...@@ -26718,7 +26718,7 @@ static IrInstGen *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstSrcFlo
26718 }26718 }
2671926719
26720 if (instr_is_comptime(target) || dest_type->id == ZigTypeIdComptimeFloat) {26720 if (instr_is_comptime(target) || dest_type->id == ZigTypeIdComptimeFloat) {
26721 return ir_analyze_widen_or_shorten(ira, &instruction->target->base, target, dest_type);26721 return ir_implicit_cast2(ira, &instruction->target->base, target, dest_type);
26722 }26722 }
2672326723
26724 if (target->value->type->id != ZigTypeIdFloat) {26724 if (target->value->type->id != ZigTypeIdFloat) {
test/stage1/behavior/cast.zig-13
...@@ -384,19 +384,6 @@ test "@intCast i32 to u7" {...@@ -384,19 +384,6 @@ test "@intCast i32 to u7" {
384 expect(z == 0xff);384 expect(z == 0xff);
385}385}
386386
387test "@floatCast cast down" {
388 {
389 var double: f64 = 0.001534;
390 var single = @floatCast(f32, double);
391 expect(@TypeOf(single) == f32);
392 }
393 {
394 const double: f64 = 0.001534;
395 const single = @floatCast(f32, double);
396 expect(@TypeOf(single) == f32);
397 }
398}
399
400test "implicit cast undefined to optional" {387test "implicit cast undefined to optional" {
401 expect(MakeType(void).getNull() == null);388 expect(MakeType(void).getNull() == null);
402 expect(MakeType(void).getNonNull() != null);389 expect(MakeType(void).getNonNull() != null);