summary refs log tree commit diff stats
path: root/tests/lookups/tmoduleclash2.nim
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2024-05-14 12:26:33 +0300
committerGitHub <noreply@github.com>2024-05-14 11:26:33 +0200
commit81a937ce1f23e443a2b60375a0961bafa5b8bd06 (patch)
tree82fcf2cc1028d5d4cd0a430412c34bf03381b62d /tests/lookups/tmoduleclash2.nim
parentc91b33aaba4234d8abdf04af102d71b86e285c58 (diff)
downloadNim-81a937ce1f23e443a2b60375a0961bafa5b8bd06.tar.gz
ignore modules when looking up symbol with expected type (#23597)
fixes #23596

When importing a module and declaring an overloadable symbol with the
same name as the module in the same scope, the module symbol can take
over and make the declared overload impossible to access. Previously
enum overloading had a quirk that bypassed this in a context where a
specific enum type was expected but this was removed in #23588. Now this
is bypassed in every place where a specific type is expected since
module symbols don't have a type and so wouldn't be compatible anyway.

But the issue still exists in places where no type is expected like `let
x = modulename`. I don't see a way of fixing this without nerfing module
symbols to the point where they're not accessible by default, which
might break some macro code.
Diffstat (limited to 'tests/lookups/tmoduleclash2.nim')
-rw-r--r--tests/lookups/tmoduleclash2.nim6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/lookups/tmoduleclash2.nim b/tests/lookups/tmoduleclash2.nim
new file mode 100644
index 000000000..958da2299
--- /dev/null
+++ b/tests/lookups/tmoduleclash2.nim
@@ -0,0 +1,6 @@
+import std/heapqueue
+proc heapqueue(x: int) = discard
+let x: proc (x: int) = heapqueue
+let y: proc = heapqueue
+when false:
+  let z = heapqueue