mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: check import duplicates
This commit is contained in:
parent
f6d74c8a37
commit
c4f672454f
@ -48,6 +48,13 @@ pub fn new_checker(table &table.Table, pref &pref.Preferences) Checker {
|
||||
|
||||
pub fn (mut c Checker) check(ast_file ast.File) {
|
||||
c.file = ast_file
|
||||
for i, ast_import in ast_file.imports {
|
||||
for j in 0..i {
|
||||
if ast_import.mod == ast_file.imports[j].mod {
|
||||
c.error('module name `$ast_import.mod` duplicate', ast_import.pos)
|
||||
}
|
||||
}
|
||||
}
|
||||
for stmt in ast_file.stmts {
|
||||
c.stmt(stmt)
|
||||
}
|
||||
|
6
vlib/v/checker/tests/import_duplicate_err.out
Normal file
6
vlib/v/checker/tests/import_duplicate_err.out
Normal file
@ -0,0 +1,6 @@
|
||||
vlib/v/checker/tests/import_duplicate_err.v:2:8: error: module name `time` duplicate
|
||||
1| import time
|
||||
2| import time
|
||||
~~~~
|
||||
3| fn main() {
|
||||
4| println(time.now().unix_time())
|
5
vlib/v/checker/tests/import_duplicate_err.vv
Normal file
5
vlib/v/checker/tests/import_duplicate_err.vv
Normal file
@ -0,0 +1,5 @@
|
||||
import time
|
||||
import time
|
||||
fn main() {
|
||||
println(time.now().unix_time())
|
||||
}
|
Loading…
Reference in New Issue
Block a user