diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2023-03-06 22:30:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-06 15:30:22 +0100 |
commit | 64a0355f3f95c9ec8ca3597f8028819b489f08c8 (patch) | |
tree | df0b1f1d7b31a799c33c24ad2c7053e234000686 /compiler/seminst.nim | |
parent | 2d9af2bd559d03c4f6b2a5f89be316f2465a091b (diff) | |
download | Nim-64a0355f3f95c9ec8ca3597f8028819b489f08c8.tar.gz |
fixes #21377; fixes `@[]` and `{}` type inference as returns in generics (#21475)
* fixes `@[]` type inference in generics * add issue links * fixes macros and iterators * refactor * add one more test
Diffstat (limited to 'compiler/seminst.nim')
-rw-r--r-- | compiler/seminst.nim | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/compiler/seminst.nim b/compiler/seminst.nim index b5fe244b0..25e5b267e 100644 --- a/compiler/seminst.nim +++ b/compiler/seminst.nim @@ -127,11 +127,18 @@ proc instantiateBody(c: PContext, n, params: PNode, result, orig: PSym) = if sfGenSym in param.flags: idTablePut(symMap, params[i].sym, result.typ.n[param.position+1].sym) freshGenSyms(c, b, result, orig, symMap) - + if sfBorrow notin orig.flags: # We do not want to generate a body for generic borrowed procs. # As body is a sym to the borrowed proc. - b = semProcBody(c, b) + let resultType = # todo probably refactor it into a function + if result.kind == skMacro: + sysTypeFromName(c.graph, n.info, "NimNode") + elif not isInlineIterator(result.typ): + result.typ[0] + else: + nil + b = semProcBody(c, b, resultType) result.ast[bodyPos] = hloBody(c, b) excl(result.flags, sfForward) trackProc(c, result, result.ast[bodyPos]) |