diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 4d4f702451..b91e93025c 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 f94cd5bce1..0902a839b8 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..