mirror of
https://github.com/vlang/v.git
synced 2025-09-16 02:49:31 -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)
|
||||
}
|
||||
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 {
|
||||
|
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