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

parser: fix error when accessing module without name after dot (#7530)

This commit is contained in:
Daniel Däschle 2020-12-25 15:50:08 +01:00 committed by GitHub
parent c6b0ce2a07
commit 1605c3b5f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -1147,7 +1147,7 @@ pub fn (mut p Parser) name_expr() ast.Expr {
// mark the imported module as used
p.register_used_import(p.tok.lit)
if p.peek_tok.kind == .dot &&
p.peek_tok2.kind != .eof && p.peek_tok2.lit[0].is_capital() {
p.peek_tok2.kind != .eof && p.peek_tok2.lit.len > 0 && p.peek_tok2.lit[0].is_capital() {
is_mod_cast = true
}
}

View File

@ -0,0 +1,5 @@
vlib/v/parser/tests/uncomplete_module_call_err.vv:7:1: error: unexpected token ``
5 | fn main() {
6 | os.
7 | }
| ^

View File

@ -0,0 +1,7 @@
module main
import os
fn main() {
os.
}