From 2578f0cbd716184f51d533c20a646e8f065d0f6b Mon Sep 17 00:00:00 2001 From: araq Date: Wed, 12 Nov 2025 22:23:52 +0100 Subject: [PATCH] progress --- compiler/liftdestructors.nim | 11 +++++++---- compiler/semtypes.nim | 5 ++++- compiler/transf.nim | 3 ++- compiler/vmgen.nim | 3 ++- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/compiler/liftdestructors.nim b/compiler/liftdestructors.nim index ef8ccfc49a..df4710a375 100644 --- a/compiler/liftdestructors.nim +++ b/compiler/liftdestructors.nim @@ -1303,11 +1303,13 @@ proc createTypeBoundOps(g: ModuleGraph; c: PContext; orig: PType; info: TLineInf ## to ensure we lift assignment, destructors and moves properly. ## The later 'injectdestructors' pass depends on it. if orig == nil or {tfCheckedForDestructor, tfHasMeta} * orig.flags != {}: return - incl orig, tfCheckedForDestructor + # IC: review this solution again later + incl orig.flagsImpl, tfCheckedForDestructor # for user defined generic destructors: let origRoot = genericRoot(orig) if origRoot != nil: - incl origRoot, tfGenericHasDestructor + # IC: review this solution again later + incl origRoot.flagsImpl, tfGenericHasDestructor let skipped = orig.skipTypes({tyGenericInst, tyAlias, tySink}) if isEmptyContainer(skipped) or skipped.kind == tyStatic: return @@ -1333,7 +1335,7 @@ proc createTypeBoundOps(g: ModuleGraph; c: PContext; orig: PType; info: TLineInf # bug #15122: We need to produce all prototypes before entering the # mind boggling recursion. Hacks like these imply we should rewrite # this module. - var generics: array[attachedWasMoved..attachedTrace, bool] = default(array[attachedWasMoved..attachedTrace, bool]) + var generics = default(array[attachedWasMoved..attachedTrace, bool]) for k in attachedWasMoved..lastAttached: generics[k] = getAttachedOp(g, canon, k) != nil if not generics[k]: @@ -1352,5 +1354,6 @@ proc createTypeBoundOps(g: ModuleGraph; c: PContext; orig: PType; info: TLineInf if not isTrivial(getAttachedOp(g, orig, attachedDestructor)): #or not isTrivial(orig.assignment) or # not isTrivial(orig.sink): - orig.incl tfHasAsgn + # IC: review this solution again later + orig.flagsImpl.incl tfHasAsgn # ^ XXX Breaks IC! diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index 3aca4ea743..a64eaaa041 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -1777,7 +1777,10 @@ proc semGeneric(c: PContext, n: PNode, s: PSym, prev: PType): PType = if not trySemObjectTypeForInheritedGenericInst(c, n, tx): return newOrPrevType(tyError, prev, c) var position = 0 - recomputeFieldPositions(tx, tx.n, position) + # it can be that we cached this generic instance. In this case, we don't have to + # recompute the field positions: + if tx.state != Sealed: + recomputeFieldPositions(tx, tx.n, position) proc maybeAliasType(c: PContext; typeExpr, prev: PType): PType = if prev != nil and (prev.kind == tyGenericBody or diff --git a/compiler/transf.nim b/compiler/transf.nim index cc97d6839e..b388b36958 100644 --- a/compiler/transf.nim +++ b/compiler/transf.nim @@ -795,7 +795,8 @@ proc transformFor(c: PTransf, n: PNode): PNode = addVar(v, copyTree(n[i][j])) # declare new vars else: if n[i].kind == nkSym and isSimpleIteratorVar(c, iter, call, n[i].sym.owner): - incl n[i].sym, sfCursor + # IC: review this solution again later + incl n[i].sym.flagsImpl, sfCursor addVar(v, copyTree(n[i])) # declare new vars stmtList.add(v) diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index 11c5a80850..0e5ab1e290 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -1550,7 +1550,8 @@ proc genAsgn(c: PCtx; dest: TDest; ri: PNode; requiresCopy: bool) = proc setSlot(c: PCtx; v: PSym) = # XXX generate type initialization here? if v.position == 0: - v.position = getFreeRegister(c, if v.kind == skLet: slotFixedLet else: slotFixedVar, start = 1) + # IC: review this solution again later + v.positionImpl = getFreeRegister(c, if v.kind == skLet: slotFixedLet else: slotFixedVar, start = 1) template cannotEval(c: PCtx; n: PNode) = if c.config.cmd == cmdCheck and c.config.m.errorOutputs != {}: