From 6f7f043c9b8c782f81568c330200d6ae8addee69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20D=C3=B6ring?= Date: Tue, 7 May 2019 08:29:17 +0200 Subject: [PATCH] Fix type recursion check (#11144) * fixes #3456 * add test #3456 --- compiler/types.nim | 9 +++++---- tests/types/tillegaltyperecursion3.nim | 10 ++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 tests/types/tillegaltyperecursion3.nim diff --git a/compiler/types.nim b/compiler/types.nim index 199bd3352..a40a94421 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -1517,11 +1517,12 @@ proc typeMismatch*(conf: ConfigRef; info: TLineInfo, formal, actual: PType) = localError(conf, info, msg) proc isTupleRecursive(t: PType, cycleDetector: var IntSet): bool = - if t == nil: return + if t == nil: + return false + if cycleDetector.containsOrIncl(t.id): + return true case t.kind: of tyTuple: - if cycleDetector.containsOrIncl(t.id): - return true var cycleDetectorCopy: IntSet for i in 0..