Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove nontoplevel type hack + consider symbol disamb in type hash #23969

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions compiler/semstmts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1785,10 +1785,6 @@ proc typeSectionFinalPass(c: PContext, n: PNode) =
checkForMetaFields(c, baseType.n, hasError)
if not hasError:
checkConstructedType(c.config, s.info, s.typ)

# fix bug #5170, bug #17162, bug #15526: ensure locally scoped types get a unique name:
if s.typ.kind in {tyEnum, tyRef, tyObject} and not isTopLevel(c):
incl(s.flags, sfGenSym)
#instAllTypeBoundOp(c, n.info)


Expand Down
4 changes: 4 additions & 0 deletions compiler/sighashes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ proc hashSym(c: var MD5Context, s: PSym) =
c &= it.name.s
c &= "."
it = it.owner
c &= "#"
c &= s.disamb

proc hashTypeSym(c: var MD5Context, s: PSym; conf: ConfigRef) =
if sfAnon in s.flags or s.kind == skGenericParam:
Expand All @@ -69,6 +71,8 @@ proc hashTypeSym(c: var MD5Context, s: PSym; conf: ConfigRef) =
c &= it.name.s
c &= "."
it = it.owner
c &= "#"
c &= s.disamb

proc hashTree(c: var MD5Context, n: PNode; flags: set[ConsiderFlag]; conf: ConfigRef) =
if n == nil:
Expand Down
9 changes: 9 additions & 0 deletions tests/ccgbugs/tsamename3.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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() == "()"
Loading