diff options
| author | Yong He <yonghe@outlook.com> | 2023-04-07 10:12:00 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-07 10:12:00 -0700 |
| commit | ea15647ba6bccb5ac48de5f4b80b8c2769d69b8f (patch) | |
| tree | 1c3568c821f1371afd15ad40507c6109377f452a /source | |
| parent | 0468cd0d1a8a1cff1d838a741b050ef11f6d7461 (diff) | |
Diagnose on attempt to specialize with interface type. (#2780)
* Diagnose on attempt to specialize with interface type.
Fixes ##1445.
* Enable fixed test.
* Fix test.
* Fix.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-check-constraint.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/slang/slang-check-constraint.cpp b/source/slang/slang-check-constraint.cpp index f96b5a484..6e9d73b61 100644 --- a/source/slang/slang-check-constraint.cpp +++ b/source/slang/slang-check-constraint.cpp @@ -469,6 +469,16 @@ namespace Slang auto sub = getSub(m_astBuilder, constraintDeclRef); auto sup = getSup(m_astBuilder, constraintDeclRef); + if (sub->equals(sup)) + { + // We are trying to use an interface type itself to conform to the + // type constraint. We can reach this case when the user code does + // not provide an explicit type parameter to specialize a generic + // and the type parameter cannot be inferred from any arguments. + // In this case, we should fail the constraint check. + return SubstitutionSet(); + } + // Search for a witness that shows the constraint is satisfied. auto subTypeWitness = tryGetSubtypeWitness(sub, sup); if(subTypeWitness) |
