diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2023-03-13 03:03:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-12 20:03:14 +0100 |
commit | ffadc75afead6baed0885877edb2c3b1c9ef1b2e (patch) | |
tree | 697bd616ab2eb1e91a2eff7eb92ba2a3f2e1283e | |
parent | af086b68f2f718a4ad20e37bf3a00d9a57abec4d (diff) | |
download | Nim-ffadc75afead6baed0885877edb2c3b1c9ef1b2e.tar.gz |
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
-rw-r--r-- | compiler/lookups.nim | 3 | ||||
-rw-r--r-- | tests/import/buzz/m21496.nim | 1 | ||||
-rw-r--r-- | tests/import/fizz/m21496.nim | 1 | ||||
-rw-r--r-- | tests/import/t21496.nim | 9 |
4 files changed, 13 insertions, 1 deletions
diff --git a/compiler/lookups.nim b/compiler/lookups.nim index e7bca08bc..3f028a52f 100644 --- a/compiler/lookups.nim +++ b/compiler/lookups.nim @@ -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. diff --git a/tests/import/buzz/m21496.nim b/tests/import/buzz/m21496.nim new file mode 100644 index 000000000..7c87e2c04 --- /dev/null +++ b/tests/import/buzz/m21496.nim @@ -0,0 +1 @@ +proc fb* = echo "buzz!" \ No newline at end of file diff --git a/tests/import/fizz/m21496.nim b/tests/import/fizz/m21496.nim new file mode 100644 index 000000000..834c11eae --- /dev/null +++ b/tests/import/fizz/m21496.nim @@ -0,0 +1 @@ +proc fb* = echo "fizz!" \ No newline at end of file diff --git a/tests/import/t21496.nim b/tests/import/t21496.nim new file mode 100644 index 000000000..568f2ac51 --- /dev/null +++ b/tests/import/t21496.nim @@ -0,0 +1,9 @@ +discard """ + errormsg: "redefinition of 'm21496'; previous declaration here: t21496.nim(5, 12)" +""" + +import fizz/m21496, buzz/m21496 + +# bug #21496 + +m21496.fb() |