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

compiler: improve module import error messages

This commit is contained in:
joe-conigliaro
2019-10-08 10:32:12 +11:00
committed by Alexander Medvednikov
parent 64349b5006
commit 9defbf989d
4 changed files with 44 additions and 24 deletions

View File

@ -437,6 +437,7 @@ fn (p mut Parser) import_statement() {
if p.peek() == .number { // && p.scanner.text[p.scanner.pos + 1] == `.` {
p.error('bad import format. module/submodule names cannot begin with a number')
}
import_tok_idx := p.token_idx-1
mut mod := p.check_name().trim_space()
mut mod_alias := mod
// submodule support
@ -457,7 +458,7 @@ fn (p mut Parser) import_statement() {
mod_alias = p.check_name()
}
// add import to file scope import table
p.import_table.register_alias(mod_alias, mod)
p.import_table.register_alias(mod_alias, mod, import_tok_idx)
// Make sure there are no duplicate imports
if mod in p.table.imports {
return