From 071f1b6062b459928ebfd6f2f60a8d6ad021112b Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 14 Aug 2024 18:41:48 -0700 Subject: Variadic Generics Part 1: parsing and type checking. (#4833) --- source/slang/slang-check-type.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'source/slang/slang-check-type.cpp') 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(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( -- cgit v1.2.3