summary refs log tree commit diff stats
path: root/tests/ccgbugs/tsamename3.nim
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2024-08-16 07:33:43 +0300
committerGitHub <noreply@github.com>2024-08-16 06:33:43 +0200
commitd43a5954c5e179c5ef270bb7b48bcab7288ddba5 (patch)
treedd0785a3c5dae4e81c655294f9b8ea46eb7b4dbe /tests/ccgbugs/tsamename3.nim
parent298ada3412c9cf5971abc2b3b891b9bb8612e170 (diff)
downloadNim-d43a5954c5e179c5ef270bb7b48bcab7288ddba5.tar.gz
remove nontoplevel type hack + consider symbol disamb in type hash (#23969)
fixes #22571

Removes the hack added in #13589 which made non-top-level object type
symbols `gensym` because they couldn't be mangled into different names
for codegen vs. top-level types. Now we consider the new `disamb` field
(added in #21667) of the type symbols in the type hash (which is used
for the mangled name) to differentiate between the types.

In other parts of the compiler, specifically the [proc
mangling](https://github.com/nim-lang/Nim/blob/298ada3412c9cf5971abc2b3b891b9bb8612e170/compiler/mangleutils.nim#L59),
`itemId.item` is used instead of the `disamb` field, but I didn't use it
in case it's the outdated method.
Diffstat (limited to 'tests/ccgbugs/tsamename3.nim')
-rw-r--r--tests/ccgbugs/tsamename3.nim9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/ccgbugs/tsamename3.nim b/tests/ccgbugs/tsamename3.nim
index a69391e5c..ded18e9f8 100644
--- a/tests/ccgbugs/tsamename3.nim
+++ b/tests/ccgbugs/tsamename3.nim
@@ -109,3 +109,12 @@ block: # make sure `hashType` doesn't recurse infinitely
       a, b: PFoo
       c: int
   var a: PFoo
+
+block: # issue #22571
+  macro foo(x: typed) =
+    result = x
+
+  block: # or `proc main =`
+    foo:
+      type Foo = object
+    doAssert $Foo() == "()"