aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-12-10 18:43:28 -0500
committerAndrew Kelley <superjoe30@gmail.com>2016-12-10 18:43:28 -0500
commit3cfbec3eef3e5949a457120287298233978cb236 (patch)
tree4f69c7779d083888a98a6e92733e93cfbe0b2579 /src/ir.cpp
parent6feae8a4e90118df26738316ab1fb49882ba6431 (diff)
downloadzig-3cfbec3eef3e5949a457120287298233978cb236.tar.gz
zig-3cfbec3eef3e5949a457120287298233978cb236.zip
IR: don't crash if number literal used with pure error
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index d21cb852c5..a97156e13a 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -3206,7 +3206,15 @@ static TypeTableEntry *ir_determine_peer_types(IrAnalyze *ira, AstNode *source_n
}
}
if (any_are_pure_error && prev_inst->type_entry->id != TypeTableEntryIdPureError) {
- return get_error_type(ira->codegen, prev_inst->type_entry);
+ if (prev_inst->type_entry->id == TypeTableEntryIdNumLitInt ||
+ prev_inst->type_entry->id == TypeTableEntryIdNumLitFloat)
+ {
+ add_node_error(ira->codegen, source_node,
+ buf_sprintf("unable to make error union out of number literal"));
+ return ira->codegen->builtin_types.entry_invalid;
+ } else {
+ return get_error_type(ira->codegen, prev_inst->type_entry);
+ }
} else {
return prev_inst->type_entry;
}