summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-decl.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-08-20 20:51:57 -0700
committerGitHub <noreply@github.com>2024-08-20 20:51:57 -0700
commitf9f6a28df40f418ddd0c8ff3b9cacccdb085e202 (patch)
treea6bafa63cee4f9bbcfe496de54af6e5727bb021e /source/slang/slang-check-decl.cpp
parent03e1e17745920c8e3a7b6f4e3b1e64062589604a (diff)
Support dependent generic constraints. (#4870)
* Support dependent generic constraints. * Fix warning. * Update comment. * Fix. * Add a test case to verify fix of #3804. * Address review.
Diffstat (limited to 'source/slang/slang-check-decl.cpp')
-rw-r--r--source/slang/slang-check-decl.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index 58fbb4689..c27e0c6f0 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -2520,18 +2520,22 @@ namespace Slang
// and likely a crash.
//
// Accessing the members via index side steps the issue.
+
+ Index parameterIndex = 0;
const auto& members = genericDecl->members;
for (Index i = 0; i < members.getCount(); ++i)
{
Decl* m = members[i];
- if (auto typeParam = as<GenericTypeParamDecl>(m))
+ if (auto typeParam = as<GenericTypeParamDeclBase>(m))
{
ensureDecl(typeParam, DeclCheckState::ReadyForReference);
+ typeParam->parameterIndex = parameterIndex++;
}
else if (auto valParam = as<GenericValueParamDecl>(m))
{
ensureDecl(valParam, DeclCheckState::ReadyForReference);
+ valParam->parameterIndex = parameterIndex++;
}
else if (auto constraint = as<GenericTypeConstraintDecl>(m))
{