Fixed variable lifetime in loops
This commit is contained in:
parent
1825a72f8c
commit
f9d72fe490
11 changed files with 90 additions and 18 deletions
17
tests/programs/loop-lifetime.q
Normal file
17
tests/programs/loop-lifetime.q
Normal file
|
@ -0,0 +1,17 @@
|
|||
main() {
|
||||
n := 10
|
||||
x := 1
|
||||
|
||||
loop {
|
||||
if n == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
f(x)
|
||||
n -= 1
|
||||
}
|
||||
}
|
||||
|
||||
f(x) {
|
||||
return x
|
||||
}
|
11
tests/programs/loop.q
Normal file
11
tests/programs/loop.q
Normal file
|
@ -0,0 +1,11 @@
|
|||
main() {
|
||||
n := 10
|
||||
|
||||
loop {
|
||||
if n == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
n -= 1
|
||||
}
|
||||
}
|
|
@ -31,6 +31,8 @@ var programs = []struct {
|
|||
{"branch-or", "", 0},
|
||||
{"branch-both", "", 0},
|
||||
{"jump-near", "", 0},
|
||||
{"loop", "", 0},
|
||||
{"loop-lifetime", "", 0},
|
||||
}
|
||||
|
||||
func TestPrograms(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue