mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix or_block in for declaration (#10317)
This commit is contained in:
parent
b28def7c11
commit
b0bafa6376
@ -5912,6 +5912,9 @@ fn (mut g Gen) or_block(var_name string, or_block ast.OrExpr, return_type ast.Ty
|
|||||||
g.indent--
|
g.indent--
|
||||||
} else {
|
} else {
|
||||||
g.stmts(stmts)
|
g.stmts(stmts)
|
||||||
|
if stmts.len > 0 && stmts[or_block.stmts.len - 1] is ast.ExprStmt {
|
||||||
|
g.writeln(';')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if or_block.kind == .propagate {
|
} else if or_block.kind == .propagate {
|
||||||
if g.file.mod.name == 'main' && (isnil(g.fn_decl) || g.fn_decl.is_main) {
|
if g.file.mod.name == 'main' && (isnil(g.fn_decl) || g.fn_decl.is_main) {
|
||||||
@ -5942,7 +5945,7 @@ fn (mut g Gen) or_block(var_name string, or_block ast.OrExpr, return_type ast.Ty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g.write('}')
|
g.writeln('}')
|
||||||
}
|
}
|
||||||
|
|
||||||
// `a in [1,2,3]` => `a == 1 || a == 2 || a == 3`
|
// `a in [1,2,3]` => `a == 1 || a == 2 || a == 3`
|
||||||
|
8
vlib/v/tests/for_in_optional_test.v
Normal file
8
vlib/v/tests/for_in_optional_test.v
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
fn test_for_in_optional() {
|
||||||
|
for d in os.read_lines(@FILE) or { panic('not found') } {
|
||||||
|
println(d)
|
||||||
|
}
|
||||||
|
assert true
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user