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

parser: correct comptime path not found error position (fix #16189) (#16209)

This commit is contained in:
yuyi 2022-10-26 14:33:58 +08:00 committed by GitHub
parent 572e26204e
commit 53c6e46a51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View File

@ -106,6 +106,7 @@ fn (mut p Parser) comptime_call() ast.ComptimeCall {
is_html := method_name == 'html'
// $env('ENV_VAR_NAME')
p.check(.lpar)
arg_pos := p.tok.pos()
if method_name in ['env', 'pkgconfig', 'compile_error', 'compile_warn'] {
s := p.tok.lit
p.check(.string)
@ -213,9 +214,9 @@ fn (mut p Parser) comptime_call() ast.ComptimeCall {
}
}
if is_html {
p.error('vweb HTML template "$path" not found')
p.error_with_pos('vweb HTML template "$tmpl_path" not found', arg_pos)
} else {
p.error('template file "$path" not found')
p.error_with_pos('template file "$tmpl_path" not found', arg_pos)
}
return err_node
}

View File

@ -0,0 +1,6 @@
vlib/v/parser/tests/comptime_path_not_found_err.vv:2:15: error: template file "tempate.txt" not found
1 | fn main() {
2 | tmp := $tmpl('tempate.txt')
| ~~~~~~~~~~~~~
3 | a := tmp
4 | }

View File

@ -0,0 +1,4 @@
fn main() {
tmp := $tmpl('tempate.txt')
a := tmp
}