diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-08-05 16:52:19 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-08-05 16:54:50 -0400 |
| commit | ad9f48b74bb5d43b767bdf401002d8bfd57c8813 (patch) | |
| tree | af4f30fc3ca17ccdcd2824ce23ec859dcc24e191 /src/ir.cpp | |
| parent | 27e4893ee59b965e4c030c43782798db258438ba (diff) | |
| download | zig-ad9f48b74bb5d43b767bdf401002d8bfd57c8813.tar.gz zig-ad9f48b74bb5d43b767bdf401002d8bfd57c8813.zip | |
fix initializing undefined and crash when casting to invalid type
closes #408
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 0f6b70316e..6525036d9e 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -6945,6 +6945,9 @@ IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node FnTableEntry *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name, IrExecutable *parent_exec) { + if (expected_type != nullptr && type_is_invalid(expected_type)) + return codegen->invalid_instruction; + IrExecutable ir_executable = {0}; ir_executable.source_node = source_node; ir_executable.parent_exec = parent_exec; @@ -14112,6 +14115,7 @@ TypeTableEntry *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutabl TypeTableEntry *expected_type, AstNode *expected_type_source_node) { assert(!old_exec->invalid); + assert(expected_type == nullptr || !type_is_invalid(expected_type)); IrAnalyze ir_analyze_data = {}; IrAnalyze *ira = &ir_analyze_data; |
