1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser: fix formatting comptime if expr script (v fmt no longer eats the body of top level $if xyz ? {}) (#19044)

This commit is contained in:
yuyi 2023-08-03 14:30:00 +08:00 committed by GitHub
parent b556f1302f
commit 5ec7ee916a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -0,0 +1,6 @@
mut pre_built_str := ''
$if prebuilt ? {
the_date := if $env('DATE') != '' { $env('DATE') } else { '##DATE##' }
pre_built_str = '[pre-built binary release (${the_date})]\n'
}
dump(pre_built_str)

View File

@ -764,7 +764,7 @@ fn (mut p Parser) top_stmt() ast.Stmt {
expr: if_expr expr: if_expr
pos: if_expr.pos pos: if_expr.pos
} }
if comptime_if_expr_contains_top_stmt(if_expr) { if p.pref.is_fmt || comptime_if_expr_contains_top_stmt(if_expr) {
return cur_stmt return cur_stmt
} else { } else {
return p.other_stmts(cur_stmt) return p.other_stmts(cur_stmt)