mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parent
2179db37ee
commit
7c9f273e33
@ -751,15 +751,20 @@ pub fn (mut p Parser) top_stmt() ast.Stmt {
|
||||
if p.peek_tok.kind == .eof {
|
||||
return p.unexpected(got: 'eof')
|
||||
}
|
||||
if_expr := p.if_expr(true)
|
||||
cur_stmt := ast.ExprStmt{
|
||||
expr: if_expr
|
||||
pos: if_expr.pos
|
||||
}
|
||||
if comptime_if_expr_contains_top_stmt(if_expr) {
|
||||
return cur_stmt
|
||||
if p.peek_tok.kind == .key_for {
|
||||
comptime_for_stmt := p.comptime_for()
|
||||
return p.other_stmts(comptime_for_stmt)
|
||||
} else {
|
||||
return p.other_stmts(cur_stmt)
|
||||
if_expr := p.if_expr(true)
|
||||
cur_stmt := ast.ExprStmt{
|
||||
expr: if_expr
|
||||
pos: if_expr.pos
|
||||
}
|
||||
if comptime_if_expr_contains_top_stmt(if_expr) {
|
||||
return cur_stmt
|
||||
} else {
|
||||
return p.other_stmts(cur_stmt)
|
||||
}
|
||||
}
|
||||
}
|
||||
.hash {
|
||||
|
10
vlib/v/slow_tests/repl/comptime_for.repl
Normal file
10
vlib/v/slow_tests/repl/comptime_for.repl
Normal file
@ -0,0 +1,10 @@
|
||||
struct Person {
|
||||
name string
|
||||
age int
|
||||
}
|
||||
$for field in Person.fields {
|
||||
println(field.name)
|
||||
}
|
||||
===output===
|
||||
name
|
||||
age
|
Loading…
Reference in New Issue
Block a user