mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
parser: add duplicate import symbol detect
This commit is contained in:
parent
9e1273ae71
commit
2b1978ab38
2 changed files with 5 additions and 18 deletions
|
@ -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)
|
||||
}
|
|
@ -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{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue