fixes #21496; Ambiguous calls compiles when module name are equal (#21500)

* fixes #21496; Ambiguous calls compiles when module name are equal

* add a test case
This commit is contained in:
ringabout 2023-03-13 03:03:14 +08:00 • committed by GitHub
commit ffadc75afe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 1 deletions

View file

@ -343,7 +343,8 @@ proc addDeclAt*(c: PContext; scope: PScope, sym: PSym, info: TLineInfo) =
if sym.name.s == "_": return
let conflict = scope.addUniqueSym(sym)
if conflict != nil:
if sym.kind == skModule and conflict.kind == skModule and sym.owner == conflict.owner:
if sym.kind == skModule and conflict.kind == skModule and
sym.position == conflict.position:
# e.g.: import foo; import foo
# xxx we could refine this by issuing a different hint for the case
# where a duplicate import happens inside an include.