type with same name in different scope now works (#17710)

* type with same name in different scope now works
* fix tests/enum/tenum.nim which was wrong because it was affected by this bug
This commit is contained in:
Timothee Cour 2021-04-13 23:50:15 -07:00 • committed by GitHub
commit 840e13deb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 133 additions and 9 deletions

View file

@ -1354,8 +1354,11 @@ 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)
# fix bug #5170, bug #17162, bug #15526: ensure locally scoped types get a unique name:
if s.typ.kind in {tyEnum, tyRef, tyObject} and not isTopLevel(c):
incl(s.flags, sfGenSym)
#instAllTypeBoundOp(c, n.info)