diff --git a/compiler/ccgcalls.nim b/compiler/ccgcalls.nim index 4dc6988a3d..140564c444 100644 --- a/compiler/ccgcalls.nim +++ b/compiler/ccgcalls.nim @@ -68,7 +68,7 @@ proc preventNrvo(p: BProc; dest, le: PNode; ri: AnyNode): bool = return true result = false - if not le.isNilNode: + if le != nil: for r in sonsFrom(ri, 1): # `isPartOf` compares field symbols by identity and so has not moved to # the seam; `origin` hands it the same nodes it always compared. @@ -79,7 +79,7 @@ proc preventNrvo(p: BProc; dest, le: PNode; ri: AnyNode): bool = locationEscapes(p, le, p.nestedTryStmts.len > 0): message(p.config, le.info, warnObservableStores, $le) # bug #19613 prevent dangerous aliasing too: - if not dest.isNilNode and dest != le: + if dest != nil and dest != le: for r in sonsFrom(ri, 1): if isPartOf(dest, origin(r), {pfStructural}) != arNo: return true diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index bdbd826e45..56cc6668c4 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -186,8 +186,10 @@ proc genRefAssign(p: BProc, dest, src: TLoc) = let rs = rdLoc(src) p.s(cpsStmts).addCallStmt(fnName, cCast(ptrType(CPointer), rad), rs) -proc asgnComplexity(n: AnyNode): int = - if not n.isNilNode: +proc asgnComplexity(n: PNode): int = + ## Walks a TYPE's record tree (`PType.n`), never a body, so it is not a + ## migration candidate — see the type-record-tree blocker in `bnode`. + if n != nil: case n.kind of nkSym: result = 1 of nkRecCase: @@ -1867,7 +1869,7 @@ proc genFieldObjConstr[F: AnyNode; V: AnyNode](p: BProc; ty: PType; useTemp, isR let field = lookupFieldAgain(p, ty, nField.sym, tmp2.snippet) if field.loc.snippet == "": fillObjectFields(p.module, ty) if field.loc.snippet == "": internalError(p.config, info, "genFieldObjConstr") - if not check.isNilNode and optFieldCheck in p.options: + if check != nil and optFieldCheck in p.options: genFieldCheck(p, check, r, field, ty) tmp2.snippet = dotField(tmp2.snippet, field.loc.snippet) if useTemp: @@ -3872,14 +3874,15 @@ proc isOpaqueImportcType(t: PType): bool = if tfCompleteStruct notin t.flags: if tfIncompleteStruct in t.flags: return true - if t.kind == tyObject and (t.n.isNilNode or not t.n.hasSons): + if t.kind == tyObject and (t.n == nil or not t.n.hasSons): return true return false proc containsOpaqueImportcField(typ: PType): bool -proc containsOpaqueImportcFieldAux(t: PType; n: AnyNode): bool = - if n.isNilNode: return false +proc containsOpaqueImportcFieldAux(t: PType; n: PNode): bool = + ## Also a type-record walk; `n` is `t.n`. + if n == nil: return false case n.kind of nkRecList: for child in sons(n): diff --git a/compiler/cgen.nim b/compiler/cgen.nim index d2933d8af0..cefd0f7f79 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -135,11 +135,11 @@ proc signatureHasMetaType*(t: PType; depth: int = 0): bool = # `HashList[T, N]`, …) is carried as a `tyStatic` node inside the otherwise # fully-concrete `tyGenericInst`, but it is NOT meta: the routine is a normal # runtime routine the owner must emit. Only an UNRESOLVED `static T` parameter - # (no bound value, `t.n.isNilNode`) is meta. Without this, every routine whose + # (no bound value, `t.n == nil`) is meta. Without this, every routine whose # signature touches a `static`-parameterized generic instance (the bulk of # the SSZ/`MDigest` API) is dropped from the owned-routine seeding and ends up # an undefined reference at link (mirrors the tyGenericBody case above). - return t.n.isNilNode + return t.n == nil if t.kind in {tyTyped, tyUntyped, tyTypeDesc, tyGenericParam, tyAnything, tyFromExpr, tyError}: return true @@ -1748,7 +1748,7 @@ when defined(newIcBackend): # `(ht . )` type difference. Only a subtree that clean is handed to # `grindPredicates` — see the descent below for why. result = true - if a.isNilNode: + if a == nil: if not c.isNilNode: bail("nil-ness", "not-nil", "nil") return if c.isNilNode: bail("nil-ness", "nil", "not-nil") @@ -1891,7 +1891,7 @@ when defined(newIcBackend): ## disagreement with the original, so both directions are checked by the one ## oracle rather than by a hand-written comparator that could agree with the ## bug. - if bnodeGrind == 0 or body.isNilNode: return + if bnodeGrind == 0 or body == nil: return let htBefore = tolHtNil let fieldBefore = tolFieldSym @@ -1908,7 +1908,7 @@ when defined(newIcBackend): # Asserted rather than assumed, with `==` on the reference: an equal copy # would not do. proc grindOrigins(enc: var BridgeBuf; c: BNode; a: PNode; path: string) = - if a.isNilNode: return + if a == nil: return # Through the AMBIENT accessor (`bnode.origin`, via `currentNav`), which # is the one a migrated generator proc will call from inside `initLoc` — # not the direct `originOf`, which would test a path nothing uses. @@ -1988,7 +1988,7 @@ when defined(newIcBackend): let ast = prc.ast if ast == nil or ast.safeLen <= bodyPos: return let body = son(ast, bodyPos) - if body.isNilNode: return + if body == nil: return var scope = default(BodyScope) var viaCursor = default(BNode) if not lazyBodyBNode(body, scope, viaCursor): return