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:
parent
c811b5343a
commit
13d7f7db8f
@ -329,12 +329,13 @@ fn (mut p Parser) at() ast.AtExpr {
|
|||||||
'@VROOT' { token.AtKind.vroot_path } // deprecated, use @VEXEROOT or @VMODROOT
|
'@VROOT' { token.AtKind.vroot_path } // deprecated, use @VEXEROOT or @VMODROOT
|
||||||
else { token.AtKind.unknown }
|
else { token.AtKind.unknown }
|
||||||
}
|
}
|
||||||
p.next()
|
expr := ast.AtExpr{
|
||||||
return ast.AtExpr{
|
|
||||||
name: name
|
name: name
|
||||||
pos: p.tok.pos()
|
pos: p.tok.pos()
|
||||||
kind: kind
|
kind: kind
|
||||||
}
|
}
|
||||||
|
p.next()
|
||||||
|
return expr
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut p Parser) comptime_selector(left ast.Expr) ast.Expr {
|
fn (mut p Parser) comptime_selector(left ast.Expr) ast.Expr {
|
||||||
|
@ -126,3 +126,11 @@ fn test_vmod_file() {
|
|||||||
fn test_comptime_at() {
|
fn test_comptime_at() {
|
||||||
assert @VEXE == pref.vexe_path()
|
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
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user