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

scanner: fix nested multiline comments (#17859)

This commit is contained in:
yuyi 2023-04-03 19:35:27 +08:00 committed by GitHub
parent 88de0decf6
commit 33ba24e933
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -1071,7 +1071,7 @@ fn (mut s Scanner) text_scan() token.Token {
s.inc_line_number()
continue
}
if s.expect('/*', s.pos) {
if s.expect('/*', s.pos) && s.text[s.pos + 2] != `/` {
nest_count++
continue
}

View File

@ -1,5 +1,19 @@
fn test_nested_multiline_comments() {
fn test_nested_multiline_comments_1() {
/*//println(os.args)
*/
assert true
}
fn test_nested_multiline_comments_2() {
tt()
assert true
}
/*
fn tt() {
}
//*/
fn tt() {
println('hello, world')
}