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

scanner: fix checking comments not terminated (fix #17842) (#17855)

This commit is contained in:
yuyi 2023-04-03 19:37:52 +08:00 committed by GitHub
parent 33ba24e933
commit a9bb6865fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View File

@ -1063,9 +1063,9 @@ fn (mut s Scanner) text_scan() token.Token {
// Skip comment
for nest_count > 0 && s.pos < s.text.len - 1 {
s.pos++
if s.pos >= s.text.len {
s.line_nr--
s.error('comment not terminated')
if s.pos >= s.text.len - 1 {
s.line_nr = start_line
s.error('unterminated multiline comment')
}
if s.text[s.pos] == scanner.b_lf {
s.inc_line_number()

View File

@ -0,0 +1,7 @@
vlib/v/scanner/tests/comments_not_terminated_err.vv:5:2: error: unterminated multiline comment
3 | }
4 |
5 | /*
| ^
6 | fn tt() {
7 | }

View File

@ -0,0 +1,7 @@
fn main() {
println('hello, world')
}
/*
fn tt() {
}