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

parser: fix line number error of comptime atExpr in the last token of the line (fix: #15672) (#15851)

This commit is contained in:
shove 2022-09-24 05:06:07 +08:00 committed by GitHub
parent c811b5343a
commit 13d7f7db8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -329,12 +329,13 @@ fn (mut p Parser) at() ast.AtExpr {
'@VROOT' { token.AtKind.vroot_path } // deprecated, use @VEXEROOT or @VMODROOT
else { token.AtKind.unknown }
}
p.next()
return ast.AtExpr{
expr := ast.AtExpr{
name: name
pos: p.tok.pos()
kind: kind
}
p.next()
return expr
}
fn (mut p Parser) comptime_selector(left ast.Expr) ast.Expr {

View File

@ -126,3 +126,11 @@ fn test_vmod_file() {
fn test_comptime_at() {
assert @VEXE == pref.vexe_path()
}
// Reasons for assertions that are not literal:
// to prevent assertion invalidation due to "line" changes in subsequent code changes
fn test_line_number_last_token() {
line1, line2, line3 := @LINE, @LINE, @LINE
assert line1 == line2
assert line1 == line3
}