diff options
| -rw-r--r-- | source/slang/slang-check-inheritance.cpp | 10 | ||||
| -rw-r--r-- | tests/bugs/gh-6488-where-lookup.slang | 11 |
2 files changed, 21 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); diff --git a/tests/bugs/gh-6488-where-lookup.slang b/tests/bugs/gh-6488-where-lookup.slang new file mode 100644 index 000000000..118a69bbe --- /dev/null +++ b/tests/bugs/gh-6488-where-lookup.slang @@ -0,0 +1,11 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv + +// CHECK: OpEntryPoint + +interface IRealArray<T : __BuiltinFloatingPointType, int D> {} +extension<T : __BuiltinFloatingPointType, int D> vector<T, D> : IRealArray<T, D> where T.Differential : __BuiltinFloatingPointType { } + + +[numthreads(1,1,1)] +void main() +{}
\ No newline at end of file |
