diff options
-rw-r--r-- | compiler/seminst.nim | 3 | ||||
-rw-r--r-- | compiler/vm.nim | 2 | ||||
-rw-r--r-- | tests/async/tgenericasync.nim | 14 |
3 files changed, 17 insertions, 2 deletions
diff --git a/compiler/seminst.nim b/compiler/seminst.nim index d7cad6a2f..338b254df 100644 --- a/compiler/seminst.nim +++ b/compiler/seminst.nim @@ -99,7 +99,8 @@ proc genericCacheGet(genericSym: PSym, entry: TInstantiation; proc freshGenSyms(n: PNode, owner, orig: PSym, symMap: var TIdTable) = # we need to create a fresh set of gensym'ed symbols: - if n.kind == nkSym and sfGenSym in n.sym.flags and n.sym.owner == orig: + if n.kind == nkSym and sfGenSym in n.sym.flags and + (n.sym.owner == orig or n.sym.owner.kind == skPackage): let s = n.sym var x = PSym(idTableGet(symMap, s)) if x == nil: diff --git a/compiler/vm.nim b/compiler/vm.nim index efcc55c59..b7af41a14 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -1421,7 +1421,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = else: regs[rc].node.strVal if k < 0 or k > ord(high(TSymKind)): internalError(c.debug[pc], "request to create symbol of invalid kind") - var sym = newSym(k.TSymKind, name.getIdent, c.module, c.debug[pc]) + var sym = newSym(k.TSymKind, name.getIdent, c.module.owner, c.debug[pc]) incl(sym.flags, sfGenSym) regs[ra].node = newSymNode(sym) of opcTypeTrait: diff --git a/tests/async/tgenericasync.nim b/tests/async/tgenericasync.nim new file mode 100644 index 000000000..ab704238a --- /dev/null +++ b/tests/async/tgenericasync.nim @@ -0,0 +1,14 @@ +discard """ + output: '''123 +abc''' +""" + +# bug #4856 + +import asyncdispatch + +proc say[T](t: T): Future[void] {.async.} = + echo $t + +waitFor(say(123)) +waitFor(say("abc")) |