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

parser: fix embed file to_string() in if guard (#16334)

This commit is contained in:
yuyi 2022-11-05 14:05:38 +08:00 committed by GitHub
parent e1896ffd5b
commit 131d07aede
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View File

@ -0,0 +1 @@
test

View File

@ -0,0 +1,9 @@
fn test_embed_file_to_string() {
s := if true {
$embed_file('./a.txt').to_string()
} else {
''
}
println(s)
assert s.trim_space() == 'test'
}

View File

@ -1002,7 +1002,7 @@ pub fn (mut p Parser) stmt(is_top_level bool) ast.Stmt {
}
.name {
mut pos := p.tok.pos()
expr := p.comptime_call()
expr := p.expr(0)
pos.update_last_line(p.prev_tok.line_nr)
return ast.ExprStmt{
expr: expr