From 282da4ac94d60d3244f4d72085e66fb82cf5abd8 Mon Sep 17 00:00:00 2001 From: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Date: Tue, 16 Apr 2024 22:01:06 -0400 Subject: Fix for unscoped enums circular reference causing an error, #3959 (#3962) --- source/slang/slang-check-decl.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source/slang/slang-check-decl.cpp') diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index d35502235..131d30d98 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -2380,8 +2380,15 @@ namespace Slang { // check the type being inherited from auto base = inheritanceDecl->base; - CheckConstraintSubType(base); - base = TranslateTypeNode(base); + Decl* toExclude = nullptr; + Decl* parent = getParentDecl(inheritanceDecl); + // We exclude in the case that a circular reference is possible. This is when a parent is a transparent decl. + // If we just blanket "block" all ensure's of a parent a generic may fail when trying to fetch a parent + if (parent->findModifier()) + toExclude = parent; + SemanticsDeclVisitorBase baseVistor(this->withDeclToExcludeFromLookup(toExclude)); + baseVistor.CheckConstraintSubType(base); + base = baseVistor.TranslateTypeNode(base); inheritanceDecl->base = base; // Note: we do not check whether the type being inherited from -- cgit v1.2.3