parser: do not fail on comment direct after import (#7071)

pull/7079/head
Lukas Neubert 2020-12-01 21:32:34 +01:00 committed by GitHub
parent 394e9c4c56
commit 8adc8ed103
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 2 deletions

View File

@ -1,4 +1,4 @@
vlib/v/checker/comparing_typesymbol_to_a_type_should_not_compile.vv:12:12: error: possible type mismatch of compared values of `==` operation vlib/v/checker/tests/comparing_typesymbol_to_a_type_should_not_compile.vv:12:12: error: possible type mismatch of compared values of `==` operation
10 | x := ityp == table.string_type 10 | x := ityp == table.string_type
11 | // the next line should produce at least a warning, or even an error, without an explicit cast: 11 | // the next line should produce at least a warning, or even an error, without an explicit cast:
12 | z := isym == table.string_type 12 | z := isym == table.string_type

View File

@ -0,0 +1,5 @@
import semver
// as semver
fn main() {
}

View File

@ -0,0 +1,4 @@
import semver// as semver
fn main() {
}

View File

@ -1624,7 +1624,7 @@ fn (mut p Parser) import_stmt() ast.Import {
} }
pos_t := p.tok.position() pos_t := p.tok.position()
if import_pos.line_nr == pos_t.line_nr { if import_pos.line_nr == pos_t.line_nr {
if p.tok.kind !in [.lcbr, .eof] { if p.tok.kind !in [.lcbr, .eof, .comment] {
p.error_with_pos('cannot import multiple modules at a time', pos_t) p.error_with_pos('cannot import multiple modules at a time', pos_t)
} }
} }