fixes #18235 - proc annotation type macro sym leak (#18249)

* fixes #18235 - proc annotation type macro sym leak

- also fixed a typo
- proc annotations guard symbol exports with shadow scopes
- symbol handling is shadow scope aware

* test for exporting an existing unexported sym

this one is for my homie alaviss.

* Special handling not needed in semProcAnnotation

* Testcasing

* [skip ci]  clean-up and add some more comments

* [skip ci] rm trailing whitespace

Co-authored-by: Clyybber <darkmine956@gmail.com>
This commit is contained in:
Saem Ghani 2021-06-14 00:21:33 -07:00 • committed by GitHub
commit 488acd9d07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 86 additions and 9 deletions

View file

@ -1844,7 +1844,7 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
# before compiling the proc params & body, set as current the scope
# where the proc was declared
let delcarationScope = c.currentScope
let declarationScope = c.currentScope
pushOwner(c, s)
openScope(c)
@ -1889,7 +1889,7 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
var (proto, comesFromShadowScope) =
if isAnon: (nil, false)
else: searchForProc(c, delcarationScope, s)
else: searchForProc(c, declarationScope, s)
if proto == nil and sfForward in s.flags:
## In cases such as a macro generating a proc with a gensymmed name we
## know `searchForProc` will not find it and sfForward will be set. In
@ -1916,9 +1916,9 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
if not hasProto and sfGenSym notin s.flags: #and not isAnon:
if s.kind in OverloadableSyms:
addInterfaceOverloadableSymAt(c, delcarationScope, s)
addInterfaceOverloadableSymAt(c, declarationScope, s)
else:
addInterfaceDeclAt(c, delcarationScope, s)
addInterfaceDeclAt(c, declarationScope, s)
pragmaCallable(c, s, n, validPragmas)
if not hasProto: