diff --git a/vlib/v/fmt/tests/import_duplicate_input.vv b/vlib/v/fmt/tests/import_duplicate_input.vv deleted file mode 100644 index 2d248cb482..0000000000 --- a/vlib/v/fmt/tests/import_duplicate_input.vv +++ /dev/null @@ -1,18 +0,0 @@ -import math -import os -import math -// keep comment -import gg -import gg { MouseButton } -import time { Duration } -import time { Duration } -import math.complex { Complex } -import math.complex { Complex } - -const mypi = math.pi -const mb = MouseButton{} -const complex = Complex{} - -fn main() { - println(os.path_separator) -} diff --git a/vlib/v/parser/module.v b/vlib/v/parser/module.v index 69df3d099f..472b7e7c2e 100644 --- a/vlib/v/parser/module.v +++ b/vlib/v/parser/module.v @@ -310,6 +310,11 @@ fn (mut p Parser) import_syms(mut parent ast.Import) { for p.tok.kind == .name { pos := p.tok.pos() alias := p.check_name() + if alias in p.imported_symbols { + p.error_with_pos('cannot register symbol `${alias}`, it was already imported', + pos) + return + } p.imported_symbols[alias] = parent.mod + '.' + alias // so we can work with this in fmt+checker parent.syms << ast.ImportSymbol{