diff options
author | Clyybber <darkmine956@gmail.com> | 2020-09-22 18:24:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-22 18:24:13 +0200 |
commit | 4b9eea2fcc5d030393ca9020fbbee33fcb48d41a (patch) | |
tree | 4024e3074ebbaf636ee0f00415f9f0861c4bf522 /compiler/semstmts.nim | |
parent | 11c377c1149a23657a7f0dd897866cb550ade8d1 (diff) | |
download | Nim-4b9eea2fcc5d030393ca9020fbbee33fcb48d41a.tar.gz |
Fix forward declarations in shadow scope contexts (#15386)
* Fix forward declarations in shadow scope contexts * Add testcase for #15385 * Less empty lines * Fix tests * Inline isShadowScope * Add original testcase (with reduced amount of iterations) * Add testcase without forward decl
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r-- | compiler/semstmts.nim | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index e99ce8937..53d381f5d 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -1898,8 +1898,8 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind, elif s.kind == skFunc: incl(s.flags, sfNoSideEffect) incl(s.typ.flags, tfNoSideEffect) - var proto: PSym = if isAnon: nil - else: searchForProc(c, oldScope, s) + var (proto, comesFromShadowScope) = if isAnon: (nil, false) + else: searchForProc(c, oldScope, s) if proto == nil and sfForward in s.flags: #This is a definition that shares its sym with its forward declaration (generated by a macro), #if the symbol is also gensymmed we won't find it with searchForProc, so we check here @@ -1941,8 +1941,9 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind, onDefResolveForward(n[namePos].info, proto) if sfForward notin proto.flags and proto.magic == mNone: wrongRedefinition(c, n.info, proto.name.s, proto.info) - excl(proto.flags, sfForward) - incl(proto.flags, sfWasForwarded) + if not comesFromShadowScope: + excl(proto.flags, sfForward) + incl(proto.flags, sfWasForwarded) closeScope(c) # close scope with wrong parameter symbols openScope(c) # open scope for old (correct) parameter symbols if proto.ast[genericParamsPos].kind != nkEmpty: |