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:

committed by
Alexander Medvednikov

parent
64349b5006
commit
9defbf989d
@ -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
|
||||
|
Reference in New Issue
Block a user