diff options
author | Clyybber <darkmine956@gmail.com> | 2020-07-29 16:17:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-29 16:17:20 +0200 |
commit | 2629d619a114f9c27b753a32da717a25906c99e6 (patch) | |
tree | 4a0e716d76da6c18877806dca852740081cb6158 /compiler/semstmts.nim | |
parent | 196e747df150ace81e7f4c01253128d4a89f03c7 (diff) | |
download | Nim-2629d619a114f9c27b753a32da717a25906c99e6.tar.gz |
Fix forward declaration issues in template/macro context (#15091)
* Fix forward declaration issues in template/macro context * Correct forward declaration resolving for overloads * Remove old dead code * WIP consistent gensym ids * Minimize diff * Remove obsoleted hack * Add templInstCounter to give unique IDs to template instantiations * Remove obsoleted code * Eh, init in myOpen, not myProcess... * Remove optNimV019 * Add testcase for #13484
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r-- | compiler/semstmts.nim | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index c88ff3609..68f0cee64 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -1898,6 +1898,10 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind, incl(s.typ.flags, tfNoSideEffect) var proto: PSym = if isAnon: nil 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 + proto = s if proto == nil: if s.kind == skIterator: if s.typ.callConv != ccClosure: @@ -1943,7 +1947,6 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind, addGenericParamListToScope(c, proto.ast[genericParamsPos]) addParams(c, proto.typ.n, proto.kind) proto.info = s.info # more accurate line information - s.typ = proto.typ proto.options = s.options s = proto n[genericParamsPos] = proto.ast[genericParamsPos] @@ -1983,7 +1986,6 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind, if n[genericParamsPos].kind == nkEmpty or usePseudoGenerics: if not usePseudoGenerics and s.magic == mNone: paramsTypeCheck(c, s.typ) - c.p.wasForwarded = proto != nil maybeAddResult(c, s, n) # semantic checking also needed with importc in case used in VM s.ast[bodyPos] = hloBody(c, semProcBody(c, n[bodyPos])) |