diff --git a/src/ir.cpp b/src/ir.cpp index 4d2221ab3..83199fc0c 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -15157,9 +15157,14 @@ static void ir_reset_result(ResultLoc *result_loc) { } break; } + case ResultLocIdVar: { + IrInstructionAllocaSrc *alloca_src = + reinterpret_cast(result_loc->source_instruction); + alloca_src->base.child = nullptr; + break; + } case ResultLocIdPeer: case ResultLocIdNone: - case ResultLocIdVar: case ResultLocIdReturn: case ResultLocIdInstruction: case ResultLocIdBitCast: diff --git a/test/stage1/behavior/eval.zig b/test/stage1/behavior/eval.zig index 49c7380f2..62cedbc76 100644 --- a/test/stage1/behavior/eval.zig +++ b/test/stage1/behavior/eval.zig @@ -190,16 +190,16 @@ fn testTryToTrickEvalWithRuntimeIf(b: bool) usize { } } -//test "inlined loop has array literal with elided runtime scope on first iteration but not second iteration" { -// var runtime = [1]i32{3}; -// comptime var i: usize = 0; -// inline while (i < 2) : (i += 1) { -// const result = if (i == 0) [1]i32{2} else runtime; -// } -// comptime { -// expect(i == 2); -// } -//} +test "inlined loop has array literal with elided runtime scope on first iteration but not second iteration" { + var runtime = [1]i32{3}; + comptime var i: usize = 0; + inline while (i < 2) : (i += 1) { + const result = if (i == 0) [1]i32{2} else runtime; + } + comptime { + expect(i == 2); + } +} fn max(comptime T: type, a: T, b: T) T { if (T == bool) { @@ -668,9 +668,9 @@ fn loopNTimes(comptime n: usize) void { inline while (i < n) : (i += 1) {} } -//test "variable inside inline loop that has different types on different iterations" { -// testVarInsideInlineLoop(true, u32(42)); -//} +test "variable inside inline loop that has different types on different iterations" { + testVarInsideInlineLoop(true, u32(42)); +} fn testVarInsideInlineLoop(args: ...) void { comptime var i = 0; @@ -681,14 +681,14 @@ fn testVarInsideInlineLoop(args: ...) void { } } -//test "inline for with same type but different values" { -// var res: usize = 0; -// inline for ([_]type{ [2]u8, [1]u8, [2]u8 }) |T| { -// var a: T = undefined; -// res += a.len; -// } -// expect(res == 5); -//} +test "inline for with same type but different values" { + var res: usize = 0; + inline for ([_]type{ [2]u8, [1]u8, [2]u8 }) |T| { + var a: T = undefined; + res += a.len; + } + expect(res == 5); +} test "refer to the type of a generic function" { const Func = fn (type) void;