authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-08 10:54:05-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-08 10:54:05-05:00
log76d0e49e612d661b57b795cd81f5ba06dc26ceca
treed4b4bc124da5cf8b3e7314a2729a0d051a51279c
parente4bc8d22c2f518353d31d8c99de8d35e5ead0c67

fix unable to eval const expr test case


2 files changed, 4 insertions(+), 2 deletions(-)

src/ir.cpp+3-1
......@@ -5266,7 +5266,9 @@ static IrInstruction *ir_exec_const_result(IrExecutable *exec) {
52665266 if (instruction->id == IrInstructionIdReturn) {
52675267 IrInstructionReturn *ret_inst = (IrInstructionReturn *)instruction;
52685268 IrInstruction *value = ret_inst->value;
5269 assert(value->value.special != ConstValSpecialRuntime);
5269 if (value->value.special == ConstValSpecialRuntime) {
5270 return nullptr;
5271 }
52705272 return value;
52715273 } else if (ir_has_side_effects(instruction)) {
52725274 return nullptr;
test/run_tests.cpp+1-1
......@@ -1128,7 +1128,7 @@ const Foo = struct {
11281128};
11291129var global_var: usize = 1;
11301130fn get() -> usize { global_var }
1131 )SOURCE", 1, ".tmp_source.zig:3:9: error: unable to evaluate constant expression");
1131 )SOURCE", 1, ".tmp_source.zig:3:12: error: unable to evaluate constant expression");
11321132
11331133
11341134 add_compile_fail_case("unnecessary if statement", R"SOURCE(