mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
@@ -751,6 +751,10 @@ pub fn (mut p Parser) top_stmt() ast.Stmt {
|
||||
if p.peek_tok.kind == .eof {
|
||||
return p.unexpected(got: 'eof')
|
||||
}
|
||||
if p.peek_tok.kind == .key_for {
|
||||
comptime_for_stmt := p.comptime_for()
|
||||
return p.other_stmts(comptime_for_stmt)
|
||||
} else {
|
||||
if_expr := p.if_expr(true)
|
||||
cur_stmt := ast.ExprStmt{
|
||||
expr: if_expr
|
||||
@@ -762,6 +766,7 @@ pub fn (mut p Parser) top_stmt() ast.Stmt {
|
||||
return p.other_stmts(cur_stmt)
|
||||
}
|
||||
}
|
||||
}
|
||||
.hash {
|
||||
return p.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
|
||||
Reference in New Issue
Block a user