mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 14:00:35 +00:00
* fix #16110 * refs #16110 * fix comment * Trigger build * use shallowCopy for efficiency
This commit is contained in:
@@ -1278,8 +1278,17 @@ proc typeSectionRightSidePass(c: PContext, n: PNode) =
|
||||
incl st.flags, tfRefsAnonObj
|
||||
let obj = newSym(skType, getIdent(c.cache, s.name.s & ":ObjectType"),
|
||||
nextId c.idgen, getCurrOwner(c), s.info)
|
||||
obj.ast = a.copyTree
|
||||
obj.ast[0] = newSymNode(obj)
|
||||
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
|
||||
|
||||
@@ -71,15 +71,30 @@ assert: check_gen_proc(len(a)) == (false, true)
|
||||
|
||||
macro check(x: type): untyped =
|
||||
let z = getType(x)
|
||||
let y = getImpl(z[1])
|
||||
echo z.treeRepr
|
||||
let y = getImpl(z[1])
|
||||
let sym = if y[0].kind == nnkSym: y[0] else: y[0][0]
|
||||
expectKind(z[1], nnkSym)
|
||||
expectKind(y[0], nnkSym)
|
||||
doAssert(y[0] == z[1])
|
||||
expectKind(sym, nnkSym)
|
||||
expectKind(y[2], nnkObjectTy)
|
||||
doAssert(sym == z[1])
|
||||
|
||||
type
|
||||
TirePtr = ptr object
|
||||
code: int
|
||||
|
||||
var z: TirePtr
|
||||
check(typeof(z[]))
|
||||
TireRef* = ref object
|
||||
code: int
|
||||
|
||||
TireRef2* {.inheritable.} = ref object
|
||||
code: int
|
||||
|
||||
TireRef3* {.inheritable.} = object
|
||||
code: int
|
||||
|
||||
var z1: TirePtr
|
||||
check(typeof(z1[]))
|
||||
var z2: TireRef
|
||||
check(typeof(z2[]))
|
||||
var z3: TireRef2
|
||||
check(typeof(z3[]))
|
||||
check(TireRef3)
|
||||
|
||||
Reference in New Issue
Block a user