From 4104ee121dc08b50b90bf9ce3b62740b60244673 Mon Sep 17 00:00:00 2001 From: Araq Date: Fri, 30 Dec 2016 00:59:10 +0100 Subject: [PATCH] fixes #5147 --- compiler/sighashes.nim | 32 +++++++++++++++---- .../ccgbugs/tsighash_typename_regression.nim | 10 ++++++ 2 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 tests/ccgbugs/tsighash_typename_regression.nim diff --git a/compiler/sighashes.nim b/compiler/sighashes.nim index 145d3ff5a0..fd2f444a69 100644 --- a/compiler/sighashes.nim +++ b/compiler/sighashes.nim @@ -82,6 +82,13 @@ else: result = 0 for x in 0..3: result = (result shl 8) or u.MD5Digest[x].int +type + ConsiderFlag* = enum + CoProc + CoType + CoOwnerSig + +proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) proc hashSym(c: var MD5Context, s: PSym) = if sfAnon in s.flags or s.kind == skGenericParam: @@ -93,6 +100,19 @@ proc hashSym(c: var MD5Context, s: PSym) = c &= "." it = it.owner +proc hashTypeSym(c: var MD5Context, s: PSym) = + if sfAnon in s.flags or s.kind == skGenericParam: + c &= ":anon" + else: + var it = s + while it != nil: + if sfFromGeneric in it.flags and it.kind in routineKinds and + it.typ != nil: + hashType c, it.typ, {CoProc} + c &= it.name.s + c &= "." + it = it.owner + proc hashTree(c: var MD5Context, n: PNode) = if n == nil: c &= "\255" @@ -118,11 +138,6 @@ proc hashTree(c: var MD5Context, n: PNode) = else: for i in 0..