From 83e715c5b6b2501c02459398a2f394c457758a55 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Thu, 5 Mar 2020 16:02:34 +0100 Subject: [PATCH] fixes #5170 (#13589) * fixes #5170 * make tests green --- compiler/semstmts.nim | 2 ++ compiler/sighashes.nim | 19 +++++++++---------- tests/errmsgs/tsigmatch.nim | 6 +++--- tests/errmsgs/tsigmatch2.nim | 4 ++-- tests/types/tissues_types.nim | 30 ++++++++++++++++++++++++++++++ 5 files changed, 46 insertions(+), 15 deletions(-) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 4d4f702451401..b91e93025c40f 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -1298,6 +1298,8 @@ proc typeSectionFinalPass(c: PContext, n: PNode) = checkConstructedType(c.config, s.info, s.typ) if s.typ.kind in {tyObject, tyTuple} and not s.typ.n.isNil: checkForMetaFields(c, s.typ.n) + # fix bug #5170: ensure locally scoped object types get a unique name: + if s.typ.kind == tyObject and not isTopLevel(c): incl(s.flags, sfGenSym) #instAllTypeBoundOp(c, n.info) diff --git a/compiler/sighashes.nim b/compiler/sighashes.nim index f94cd5bce16b3..0902a839b8d23 100644 --- a/compiler/sighashes.nim +++ b/compiler/sighashes.nim @@ -35,6 +35,7 @@ type CoIgnoreRange CoConsiderOwned CoDistinct + CoHashTypeInsideNode proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) @@ -61,7 +62,7 @@ proc hashTypeSym(c: var MD5Context, s: PSym) = c &= "." it = it.owner -proc hashTree(c: var MD5Context, n: PNode) = +proc hashTree(c: var MD5Context, n: PNode; flags: set[ConsiderFlag]) = if n == nil: c &= "\255" return @@ -75,6 +76,8 @@ proc hashTree(c: var MD5Context, n: PNode) = c &= n.ident.s of nkSym: hashSym(c, n.sym) + if CoHashTypeInsideNode in flags and n.sym.typ != nil: + hashType(c, n.sym.typ, flags) of nkCharLit..nkUInt64Lit: let v = n.intVal lowlevel v @@ -84,7 +87,7 @@ proc hashTree(c: var MD5Context, n: PNode) = of nkStrLit..nkTripleStrLit: c &= n.strVal else: - for i in 0..