From fcaacbf374c4bba2b281b6edf7d1f18959af8d36 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Fri, 12 May 2023 02:49:47 +0800 Subject: [PATCH] cursor fields cannot form reference cycles (#21832) * cursor fields cannot form a reference cycle * fixes typo * fixes position (cherry picked from commit ebbad9e9604d778c32838c981c8748f3675d2659) --- compiler/types.nim | 21 ++++++++++++--------- tests/types/tcyclic.nim | 20 ++++++++++++++++---- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/compiler/types.nim b/compiler/types.nim index d591ce4f62..54dc551cbe 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -372,15 +372,18 @@ proc canFormAcycleAux(g: ModuleGraph; marker: var IntSet, typ: PType, orig: PTyp proc canFormAcycleNode(g: ModuleGraph; marker: var IntSet, n: PNode, orig: PType, withRef: bool, hasTrace: bool): bool = result = false if n != nil: - result = canFormAcycleAux(g, marker, n.typ, orig, withRef, hasTrace) - if not result: - case n.kind - of nkNone..nkNilLit: - discard - else: - for i in 0..