Skip to content
Closed
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
3 changes: 3 additions & 0 deletions compiler/sighashes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) =
# make the hash different from the one we produce by hashing only the
# type name.
c &= ".empty"
else:
if sfCompilerProc notin t.sym.flags:
c &= t.id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It we use the id regardless there is no reason to do this convoluted way of doing things. Instead hashSym needs to take into account "module1" vs "module2" but that doesn't work either. Not sure what to do here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before this module1 and module2 just hash its type kind, without if condition will produce duplicated TNimType, that's all I get.

Copy link
Collaborator

@beef331 beef331 Oct 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the lineInfo's FileIndex be used, or is that not temporally consistent enough?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not consistent enough for my taste. There is a better way but it's pretty intrusive...

else:
c &= t.id
if t.len > 0 and t[0] != nil:
Expand Down
2 changes: 2 additions & 0 deletions tests/modules/module1/defs.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type MyObj* = object
field1*: int
2 changes: 2 additions & 0 deletions tests/modules/module2/defs.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type MyObj* = object
field2*: int
6 changes: 6 additions & 0 deletions tests/modules/tmoduleconflict.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import module1/defs as md1
import module2/defs as md2

let x = md1.MyObj(field1: 1)
let y = md2.MyObj(field2: 1)
doAssert x.field1 == y.field2