correct effect tracking for .borrowed procs [backport] (#18882)

* correct effect tracking for .borrowed procs [backport]

* progress

* fix error message in a test

* correctly fix it

Co-authored-by: narimiran <narimiran@disroot.org>
This commit is contained in:
Andreas Rumpf 2021-09-23 16:47:24 +02:00 • committed by GitHub
commit 90a2b5afd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 20 additions and 12 deletions

View file

@ -1474,6 +1474,9 @@ proc semBorrow(c: PContext, n: PNode, s: PSym) =
# Carry over the original symbol magic, this is necessary in order to ensure
# the semantic pass is correct
s.magic = b.magic
if b.typ != nil and b.typ.len > 0:
s.typ.n[0] = b.typ.n[0]
s.typ.flags = b.typ.flags
else:
localError(c.config, n.info, errNoSymbolToBorrowFromFound)
@ -1954,7 +1957,7 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
if not hasProto:
implicitPragmas(c, s, n.info, validPragmas)
if n[pragmasPos].kind != nkEmpty:
if n[pragmasPos].kind != nkEmpty and sfBorrow notin s.flags:
setEffectsForProcType(c.graph, s.typ, n[pragmasPos], s)
s.typ.flags.incl tfEffectSystemWorkaround