diff --git a/compiler/sighashes.nim b/compiler/sighashes.nim index d6db0b0fa0..7705ff62d9 100644 --- a/compiler/sighashes.nim +++ b/compiler/sighashes.nim @@ -190,9 +190,10 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]; conf: Confi if CoConsiderOwned in flags: c &= char(t.kind) c.hashType t.skipModifier, flags, conf - of tyBool, tyChar, tyInt..tyUInt64: - # no canonicalization for integral types, so that e.g. ``pid_t`` is - # produced instead of ``NI``: + of tyBool, tyChar, tyPointer, tyCstring, tyInt..tyUInt64: + # no canonicalization for builtin scalar-ish / pointer-like types, so + # that e.g. ``pid_t`` or an imported ``pointer`` alias keep their + # backend spelling instead of collapsing into the generic Nim builtin: c &= char(t.kind) if t.sym != nil and {sfImportc, sfExportc} * t.sym.flags != {}: c.hashSym(t.sym) @@ -533,4 +534,3 @@ proc idOrSig*(s: PSym, currentModule: string, if counter != 0: result.add "_" & rope(counter+1) sigCollisions.inc(sig) - diff --git a/tests/ccgbugs/tsighash_typename_regression.nim b/tests/ccgbugs/tsighash_typename_regression.nim index b93eebd204..e9aa7df712 100644 --- a/tests/ccgbugs/tsighash_typename_regression.nim +++ b/tests/ccgbugs/tsighash_typename_regression.nim @@ -30,3 +30,13 @@ block: var x = M(x: 1) doAssert(x.x == 1) + +block: # bug #25931 + type + N {.importc: "const void *".} = pointer + S = object + f: proc (_: N) {.cdecl.} + #var _: proc (_: pointer) {.cdecl.} + proc d(_: proc (_: pointer) {.cdecl.}) = discard + discard S() + d(proc (_: pointer) {.cdecl.} = discard)