From d49d6f0cde782f4ec3c1d623d58644c3e51a6ce9 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 18 Jun 2018 11:04:18 -0400 Subject: fix compiler crash when using @intToFloat with float literal closes #1132 --- src/ir.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/ir.cpp') diff --git a/src/ir.cpp b/src/ir.cpp index e6339a72f6..a312b501ab 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -17602,6 +17602,12 @@ static TypeTableEntry *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrIns if (type_is_invalid(target->value.type)) return ira->codegen->builtin_types.entry_invalid; + if (target->value.type->id != TypeTableEntryIdInt && target->value.type->id != TypeTableEntryIdComptimeInt) { + ir_add_error(ira, instruction->target, buf_sprintf("expected int type, found '%s'", + buf_ptr(&target->value.type->name))); + return ira->codegen->builtin_types.entry_invalid; + } + IrInstruction *result = ir_resolve_cast(ira, &instruction->base, target, dest_type, CastOpIntToFloat, false); ir_link_new_instruction(result, &instruction->base); return dest_type; -- cgit v1.2.3