summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-02-28 00:57:56 -0800
committerGitHub <noreply@github.com>2025-02-28 08:57:56 +0000
commitceb3af59f797ec60249debd614db13dd6902de12 (patch)
tree2c9f3f34bca2fe94d075dd60bcad4286d50d1b95 /source/slang
parenta09d554721ecf0c6d967d5f55b3416e3284e71f2 (diff)
Fix member lookup in left hand side of `where` clause. (#6490)
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-check-inheritance.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/slang/slang-check-inheritance.cpp b/source/slang/slang-check-inheritance.cpp
index b44858874..cef9b6a09 100644
--- a/source/slang/slang-check-inheritance.cpp
+++ b/source/slang/slang-check-inheritance.cpp
@@ -460,6 +460,9 @@ InheritanceInfo SharedSemanticsContext::_calcInheritanceInfo(
}
}
+ bool selfIsGenericParamType =
+ isDeclRefTypeOf<GenericTypeParamDeclBase>(selfType) != nullptr;
+
for (auto constraintDeclRef :
getMembersOfType<GenericTypeConstraintDecl>(astBuilder, genericDeclRef))
{
@@ -471,6 +474,13 @@ InheritanceInfo SharedSemanticsContext::_calcInheritanceInfo(
// Check only the sub-type.
visitor.CheckConstraintSubType(constraintDeclRef.getDecl()->sub);
auto sub = constraintDeclRef.getDecl()->sub;
+
+ // If the sub-type part of the generic constraint is a member expression, it can't
+ // possibly be defining a constraint for a generic type parameter, so we skip it
+ // to avoid circular checking on the generic param type.
+ if (selfIsGenericParamType && as<MemberExpr>(sub.exp))
+ continue;
+
if (!sub.type)
sub = visitor.TranslateTypeNodeForced(sub);
auto subType = constraintDeclRef.substitute(astBuilder, sub.type);