diff options
| author | Yong He <yonghe@outlook.com> | 2024-08-14 18:41:48 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-14 18:41:48 -0700 |
| commit | 071f1b6062b459928ebfd6f2f60a8d6ad021112b (patch) | |
| tree | 2ba65eb40f39701db6fc775a9258ec8079d161a0 /source/slang/slang-check-type.cpp | |
| parent | 35a3d32c87f079749f6b100d01b289c3da02d7d6 (diff) | |
Variadic Generics Part 1: parsing and type checking. (#4833)
Diffstat (limited to 'source/slang/slang-check-type.cpp')
| -rw-r--r-- | source/slang/slang-check-type.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/source/slang/slang-check-type.cpp b/source/slang/slang-check-type.cpp index 217d1b545..eeee13561 100644 --- a/source/slang/slang-check-type.cpp +++ b/source/slang/slang-check-type.cpp @@ -389,7 +389,7 @@ namespace Slang return CoerceToProperType(TranslateTypeNode(typeExp)); } - TypeExp SemanticsVisitor::CoerceToUsableType(TypeExp const& typeExp) + TypeExp SemanticsVisitor::CoerceToUsableType(TypeExp const& typeExp, Decl* decl) { TypeExp result = CoerceToProperType(typeExp); Type* type = result.type; @@ -404,12 +404,20 @@ namespace Slang return result; } } + + // A type pack is not a usable type other than for defining parameters. + if (!as<ParamDecl>(decl) && isTypePack(type)) + { + getSink()->diagnose(typeExp.exp, Diagnostics::improperUseOfType, typeExp.type); + result.type = m_astBuilder->getErrorType(); + return result; + } return result; } - TypeExp SemanticsVisitor::CheckUsableType(TypeExp typeExp) + TypeExp SemanticsVisitor::CheckUsableType(TypeExp typeExp, Decl* decl) { - return CoerceToUsableType(TranslateTypeNode(typeExp)); + return CoerceToUsableType(TranslateTypeNode(typeExp), decl); } bool SemanticsVisitor::ValuesAreEqual( |
