fmt: fix ForInStmt
parent
5a7f683f61
commit
9c668072b9
|
@ -178,9 +178,15 @@ fn (f mut Fmt) stmt(node ast.Stmt) {
|
|||
f.writeln('}\n')
|
||||
}
|
||||
ast.ForInStmt {
|
||||
f.write('for $it.key_var')
|
||||
f.write('for ')
|
||||
if it.key_var != '' {
|
||||
f.write(it.key_var)
|
||||
}
|
||||
if it.val_var != '' {
|
||||
f.write(', $it.val_var')
|
||||
if it.key_var != '' {
|
||||
f.write(', ')
|
||||
}
|
||||
f.write(it.val_var)
|
||||
}
|
||||
f.write(' in ')
|
||||
f.expr(it.cond)
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
fn for_in_loop() {
|
||||
for item in arr {
|
||||
println(item)
|
||||
}
|
||||
}
|
||||
|
||||
fn for_in_loop_with_counter() {
|
||||
for i, item in arr {
|
||||
println(item)
|
||||
}
|
||||
}
|
||||
|
||||
fn for_in_loop_with_index_expr() {
|
||||
for i in 0 .. 10 {
|
||||
println(i)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
fn for_in_loop() {
|
||||
for item in arr {
|
||||
println(item)
|
||||
}
|
||||
}
|
||||
|
||||
fn for_in_loop_with_counter() {
|
||||
for i, item in arr {
|
||||
println(item)
|
||||
}
|
||||
}
|
||||
|
||||
fn for_in_loop_with_index_expr() {
|
||||
for i in 0..10 {
|
||||
println(i)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue