diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index d7f83397ee..6fa7572375 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -477,7 +477,7 @@ proc semLowerLetVarCustomPragma(c: PContext, a: PNode, n: PNode): PNode = proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode = if n.len == 1: result = semLowerLetVarCustomPragma(c, n[0], n) - if result!=nil: return result + if result != nil: return result var b: PNode result = copyNode(n) @@ -513,7 +513,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode = def = fitNode(c, typ, def, def.info) #changeType(def.skipConv, typ, check=true) else: - typ = def.typ.skipTypes({tyStatic}).skipIntLit + typ = def.typ.skipTypes({tyStatic, tySink}).skipIntLit if typ.kind in tyUserTypeClasses and typ.isResolvedUserTypeClass: typ = typ.lastSon if hasEmpty(typ): @@ -1276,9 +1276,18 @@ proc typeSectionRightSidePass(c: PContext, n: PNode) = internalAssert c.config, st.lastSon.sym == nil incl st.flags, tfRefsAnonObj let obj = newSym(skType, getIdent(c.cache, s.name.s & ":ObjectType"), - getCurrOwner(c), s.info) - obj.ast = a.copyTree - obj.ast[0] = newSymNode(obj) + getCurrOwner(c), s.info) + let symNode = newSymNode(obj) + obj.ast = a.shallowCopy + case a[0].kind + of nkSym: obj.ast[0] = symNode + of nkPragmaExpr: + obj.ast[0] = a[0].shallowCopy + obj.ast[0][0] = symNode + obj.ast[0][1] = a[0][1] + else: assert(false) + obj.ast[1] = a[1] + obj.ast[2] = a[2][0] if sfPure in s.flags: obj.flags.incl sfPure obj.typ = st.lastSon