test: 添加嵌套循环变量作用域测试代码

This commit is contained in:
Luke 2025-07-29 11:50:32 +08:00
parent 63835a1cce
commit f1699bfbbe
2 changed files with 56 additions and 0 deletions

View 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

View 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