test: 添加嵌套循环变量作用域测试代码
This commit is contained in:
parent
63835a1cce
commit
f1699bfbbe
45
playground/BugFarm/Bug2/Main.snow
Normal file
45
playground/BugFarm/Bug2/Main.snow
Normal file
@ -0,0 +1,45 @@
|
||||
module: Main
|
||||
import: os
|
||||
function: main
|
||||
parameter:
|
||||
return_type: int
|
||||
body:
|
||||
loop:
|
||||
init:
|
||||
declare outer_i: int = 1
|
||||
cond:
|
||||
outer_i <= 10
|
||||
step:
|
||||
outer_i = outer_i + 1
|
||||
body:
|
||||
print(outer_i)
|
||||
|
||||
loop:
|
||||
init:
|
||||
// 注意这一行使用了外层循环的变量 outer_i
|
||||
declare inter_j: int = outer_i
|
||||
cond:
|
||||
inter_j <= 10
|
||||
step:
|
||||
inter_j = inter_j + 1
|
||||
body:
|
||||
|
||||
end body
|
||||
end loop
|
||||
|
||||
end body
|
||||
end loop
|
||||
|
||||
return 0
|
||||
end body
|
||||
end function
|
||||
|
||||
function: print
|
||||
parameter:
|
||||
declare i1: int
|
||||
return_type: void
|
||||
body:
|
||||
syscall("PRINT",i1)
|
||||
end body
|
||||
end function
|
||||
end module
|
||||
11
playground/BugFarm/Bug2/OS.snow
Normal file
11
playground/BugFarm/Bug2/OS.snow
Normal file
@ -0,0 +1,11 @@
|
||||
module: os
|
||||
import: os
|
||||
function: print
|
||||
parameter:
|
||||
declare i1: int
|
||||
return_type: void
|
||||
body:
|
||||
syscall("PRINT",i1)
|
||||
end body
|
||||
end function
|
||||
end module
|
||||
Loading…
x
Reference in New Issue
Block a user