diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-01-08 10:54:05 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-01-08 10:54:05 -0500 |
| commit | 76d0e49e612d661b57b795cd81f5ba06dc26ceca (patch) | |
| tree | d4b4bc124da5cf8b3e7314a2729a0d051a51279c | |
| parent | e4bc8d22c2f518353d31d8c99de8d35e5ead0c67 (diff) | |
| download | zig-76d0e49e612d661b57b795cd81f5ba06dc26ceca.tar.gz zig-76d0e49e612d661b57b795cd81f5ba06dc26ceca.zip | |
fix unable to eval const expr test case
| -rw-r--r-- | src/ir.cpp | 4 | ||||
| -rw-r--r-- | test/run_tests.cpp | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 5554e10215..b2842a7473 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -5266,7 +5266,9 @@ static IrInstruction *ir_exec_const_result(IrExecutable *exec) { if (instruction->id == IrInstructionIdReturn) { IrInstructionReturn *ret_inst = (IrInstructionReturn *)instruction; IrInstruction *value = ret_inst->value; - assert(value->value.special != ConstValSpecialRuntime); + if (value->value.special == ConstValSpecialRuntime) { + return nullptr; + } return value; } else if (ir_has_side_effects(instruction)) { return nullptr; diff --git a/test/run_tests.cpp b/test/run_tests.cpp index 6083dfd8f6..94710f37cc 100644 --- a/test/run_tests.cpp +++ b/test/run_tests.cpp @@ -1128,7 +1128,7 @@ const Foo = struct { }; var global_var: usize = 1; fn get() -> usize { global_var } - )SOURCE", 1, ".tmp_source.zig:3:9: error: unable to evaluate constant expression"); + )SOURCE", 1, ".tmp_source.zig:3:12: error: unable to evaluate constant expression"); add_compile_fail_case("unnecessary if statement", R"SOURCE( |
