aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-06-18 11:04:18 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-06-18 11:04:18 -0400
commitd49d6f0cde782f4ec3c1d623d58644c3e51a6ce9 (patch)
treec433020e6b41a8d465ed3708e5aadcef5e745a20 /src/ir.cpp
parent7151d72532ebc11fe72fda91d156082bd8c1761b (diff)
downloadzig-d49d6f0cde782f4ec3c1d623d58644c3e51a6ce9.tar.gz
zig-d49d6f0cde782f4ec3c1d623d58644c3e51a6ce9.zip
fix compiler crash when using @intToFloat with float literal
closes #1132
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp6
1 files changed, 6 insertions, 0 deletions
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;