Skip to content

Commit

Permalink
fixes #22208; Ambiguous error when import modules with same names but… (
Browse files Browse the repository at this point in the history
#22211)

fixes #22208; Ambiguous error when import modules with same names but different aliases

(cherry picked from commit d9a24b9)
  • Loading branch information
ringabout authored and narimiran committed Aug 11, 2023
1 parent 80ece59 commit 01ef1e1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion compiler/importer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ proc importModuleAs(c: PContext; n: PNode, realModule: PSym, importHidden: bool)
result.options.incl optImportHidden
c.unusedImports.add((result, n.info))
c.importModuleMap[result.id] = realModule.id
c.importModuleLookup.mgetOrPut(realModule.name.id, @[]).addUnique realModule.id
c.importModuleLookup.mgetOrPut(result.name.id, @[]).addUnique realModule.id

proc transformImportAs(c: PContext; n: PNode): tuple[node: PNode, importHidden: bool] =
var ret: typeof(result)
Expand Down
3 changes: 3 additions & 0 deletions parse/pragmas.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# parse/pragmas.nim content

proc foo*() = discard
2 changes: 1 addition & 1 deletion tests/import/buzz/m21496.nim
Original file line number Diff line number Diff line change
@@ -1 +1 @@
proc fb* = echo "buzz!"
proc fb*: string = "buzz!"
2 changes: 1 addition & 1 deletion tests/import/fizz/m21496.nim
Original file line number Diff line number Diff line change
@@ -1 +1 @@
proc fb* = echo "fizz!"
proc fb*: string = "fizz!"
2 changes: 1 addition & 1 deletion tests/import/t21496.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import fizz/m21496, buzz/m21496

# bug #21496

m21496.fb()
discard m21496.fb()
6 changes: 6 additions & 0 deletions tests/import/t22208.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import fizz/m21496 as alas
import buzz/m21496

# bug #21496

doAssert m21496.fb() == "buzz!"

0 comments on commit 01ef1e1

Please sign in to comment.