summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-10-16 11:23:13 -0700
committerGitHub <noreply@github.com>2025-10-16 18:23:13 +0000
commitbedc3421c9e1e0837fa69e30396a27a60f0fee53 (patch)
tree4ac8a8f5a4fbfc5f601cd60f82e73e29664123ba /source
parentd8b732d7ba6d31a724cb18dc93f60d8bcc522c19 (diff)
Fix use of variadic generics with [Differentiable]. (#8736)
There was a bug that causes the compiler failing to treat a `no_diff TypePack` as a type pack, and thus diagnose an error when resolving the following call. The fix is to unwrap any ModifiedType wrappers in `IsTypePack()` check.
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-ast-type.cpp3
-rw-r--r--source/slang/slang-ast-val.h4
2 files changed, 7 insertions, 0 deletions
diff --git a/source/slang/slang-ast-type.cpp b/source/slang/slang-ast-type.cpp
index e3f75cb2f..bfa347df3 100644
--- a/source/slang/slang-ast-type.cpp
+++ b/source/slang/slang-ast-type.cpp
@@ -4,6 +4,7 @@
#include "slang-ast-builder.h"
#include "slang-ast-dispatch.h"
#include "slang-ast-modifier.h"
+#include "slang-check.h"
#include "slang-syntax.h"
#include <assert.h>
@@ -13,6 +14,7 @@ namespace Slang
bool isAbstractTypePack(Type* type)
{
+ type = unwrapModifiedType(type);
if (as<ExpandType>(type))
return true;
if (isDeclRefTypeOf<GenericTypePackParamDecl>(type))
@@ -22,6 +24,7 @@ bool isAbstractTypePack(Type* type)
bool isTypePack(Type* type)
{
+ type = unwrapModifiedType(type);
if (as<ConcreteTypePack>(type))
return true;
return isAbstractTypePack(type);
diff --git a/source/slang/slang-ast-val.h b/source/slang/slang-ast-val.h
index 7b9462f2f..d4edaae08 100644
--- a/source/slang/slang-ast-val.h
+++ b/source/slang/slang-ast-val.h
@@ -1014,6 +1014,10 @@ inline bool isTypeEqualityWitness(Val* witness)
}
return true;
}
+ else if (auto expandWitness = as<ExpandSubtypeWitness>(witness))
+ {
+ return isTypeEqualityWitness(expandWitness->getPatternTypeWitness());
+ }
return false;
}