mirror of
https://github.com/vlang/v.git
synced 2025-09-17 11:26:17 -04:00
v.markused: process the init statements in for init; cond; inc {
too (#22908)
This commit is contained in:
parent
faac1fd31c
commit
ae0fdbd834
@ -154,8 +154,15 @@ pub fn (mut w Walker) stmt(node_ ast.Stmt) {
|
|||||||
w.fn_decl(mut node)
|
w.fn_decl(mut node)
|
||||||
}
|
}
|
||||||
ast.ForCStmt {
|
ast.ForCStmt {
|
||||||
|
if node.has_init {
|
||||||
|
w.stmt(node.init)
|
||||||
|
}
|
||||||
|
if node.has_cond {
|
||||||
w.expr(node.cond)
|
w.expr(node.cond)
|
||||||
|
}
|
||||||
|
if node.has_inc {
|
||||||
w.stmt(node.inc)
|
w.stmt(node.inc)
|
||||||
|
}
|
||||||
w.stmts(node.stmts)
|
w.stmts(node.stmts)
|
||||||
}
|
}
|
||||||
ast.ForInStmt {
|
ast.ForInStmt {
|
||||||
@ -179,7 +186,9 @@ pub fn (mut w Walker) stmt(node_ ast.Stmt) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast.ForStmt {
|
ast.ForStmt {
|
||||||
|
if !node.is_inf {
|
||||||
w.expr(node.cond)
|
w.expr(node.cond)
|
||||||
|
}
|
||||||
w.stmts(node.stmts)
|
w.stmts(node.stmts)
|
||||||
}
|
}
|
||||||
ast.Return {
|
ast.Return {
|
||||||
|
5
vlib/v/tests/skip_unused/for_c_stmt.run.out
Normal file
5
vlib/v/tests/skip_unused/for_c_stmt.run.out
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
ok
|
||||||
|
12
|
||||||
|
13
|
||||||
|
14
|
||||||
|
ok
|
5
vlib/v/tests/skip_unused/for_c_stmt.skip_unused.run.out
Normal file
5
vlib/v/tests/skip_unused/for_c_stmt.skip_unused.run.out
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
ok
|
||||||
|
12
|
||||||
|
13
|
||||||
|
14
|
||||||
|
ok
|
10
vlib/v/tests/skip_unused/for_c_stmt.vv
Normal file
10
vlib/v/tests/skip_unused/for_c_stmt.vv
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
const abc = 12
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println('ok')
|
||||||
|
for x := abc; x<15;x++ {
|
||||||
|
println(x)
|
||||||
|
}
|
||||||
|
println('ok')
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user