Skip to content

Commit c5a1acd

Browse files
committed
Fix + test for assignment in value but not tail position
1 parent c92584c commit c5a1acd

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/linear_ir.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,6 @@ function compile(ctx::LinearIRContext, ex, needs_value, in_tail_pos)
666666
if in_tail_pos
667667
emit_return(ctx, ex, r)
668668
else
669-
@assert false "If this code is reachable, add a test case"
670669
r
671670
end
672671
else

test/assignments.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ let
2323
end
2424
""") == 42
2525

26+
# Assignment in value but not tail position
27+
@test JuliaLowering.include_string(test_mod, """
28+
let
29+
x = begin
30+
y = 42
31+
end
32+
x
33+
end
34+
""") == 42
35+
2636
@test JuliaLowering.include_string(test_mod, """
2737
let
2838
x = []

test/assignments_ir.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ end
2323
5 (= slot₃/c %₂)
2424
6 (return %₂)
2525

26+
########################################
27+
# Assignment in value but not tail position
28+
let
29+
x = begin
30+
y = 42
31+
end
32+
x
33+
end
34+
#---------------------
35+
1 42
36+
2 (= slot₂/y %₁)
37+
3 (= slot₁/x %₁)
38+
4 slot₁/x
39+
5 (return %₄)
40+
2641
########################################
2742
# short form function def, not chain of assignments
2843
begin

0 commit comments

Comments
 (0)