v.markused: process the init statements in for init; cond; inc { too (#22908)

This commit is contained in:
Delyan Angelov 2024-11-19 08:36:26 +02:00 committed by GitHub
parent faac1fd31c
commit ae0fdbd834
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 32 additions and 3 deletions

View File

@ -154,8 +154,15 @@ pub fn (mut w Walker) stmt(node_ ast.Stmt) {
w.fn_decl(mut node)
}
ast.ForCStmt {
w.expr(node.cond)
w.stmt(node.inc)
if node.has_init {
w.stmt(node.init)
}
if node.has_cond {
w.expr(node.cond)
}
if node.has_inc {
w.stmt(node.inc)
}
w.stmts(node.stmts)
}
ast.ForInStmt {
@ -179,7 +186,9 @@ pub fn (mut w Walker) stmt(node_ ast.Stmt) {
}
}
ast.ForStmt {
w.expr(node.cond)
if !node.is_inf {
w.expr(node.cond)
}
w.stmts(node.stmts)
}
ast.Return {

View File

@ -0,0 +1,5 @@
ok
12
13
14
ok

View File

@ -0,0 +1,5 @@
ok
12
13
14
ok

View File

@ -0,0 +1,10 @@
const abc = 12
fn main() {
println('ok')
for x := abc; x<15;x++ {
println(x)
}
println('ok')
}