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:
parent
b556f1302f
commit
5ec7ee916a
6
vlib/v/fmt/tests/comptime_if_expr_script_keep.vv
Normal file
6
vlib/v/fmt/tests/comptime_if_expr_script_keep.vv
Normal 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)
|
@ -764,7 +764,7 @@ fn (mut p Parser) top_stmt() ast.Stmt {
|
||||
expr: if_expr
|
||||
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
|
||||
} else {
|
||||
return p.other_stmts(cur_stmt)
|
||||
|
Loading…
Reference in New Issue
Block a user