From d260855f35dee424b86e19c8d264266a7dadce62 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Wed, 15 Oct 2025 13:24:48 +0800 Subject: [PATCH] fixes #25048; Closure environment wrongly marked as cyclic (#25220) fixes #25048 ```nim proc canFormAcycleAux = of tyObject: # Inheritance can introduce cyclic types, however this is not relevant # as the type that is passed to 'new' is statically known! # er but we use it also for the write barrier ... if tfFinal notin t.flags: # damn inheritance may introduce cycles: result = true ``` It seems that all objects without `tfFinal` in their flags are registering cycles. It doesn't seem that `Env` can be a cyclic type because of inheritance since it is not going to be inherited after all by another `Env` object type (cherry picked from commit f191ba8dddb3e61fb013a4fa9771bd95272faaa7) --- compiler/lambdalifting.nim | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim index c8c5acf974..048b286aae 100644 --- a/compiler/lambdalifting.nim +++ b/compiler/lambdalifting.nim @@ -150,6 +150,7 @@ template isIterator*(owner: PSym): bool = proc createEnvObj(g: ModuleGraph; idgen: IdGenerator; owner: PSym; info: TLineInfo): PType = result = createObj(g, idgen, owner, info, final=false) + result.flags.incl tfFinal if owner.isIterator: rawAddField(result, createStateField(g, owner, idgen))