From 5bd366fa1d10b93d0460f7779fa24d1572c971ba Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 23 Jun 2022 11:53:24 -0700 Subject: Define proper diagnostic item for two common "unimplemented" cases. (#2296) --- source/slang/slang-check-decl.cpp | 14 +++++++++++--- source/slang/slang-diagnostic-defs.h | 3 +++ 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'source/slang') diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index 7871d35dd..94858b679 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -3039,8 +3039,13 @@ namespace Slang return true; } } - - getSink()->diagnose(inheritanceDecl, Diagnostics::unimplemented, "type not supported for inheritance"); + if (!as(superType)) + { + getSink()->diagnose( + inheritanceDecl, + Diagnostics::invalidTypeForInheritance, + superType); + } return false; } @@ -4566,7 +4571,10 @@ namespace Slang return; } } - getSink()->diagnose(decl->targetType.exp, Diagnostics::unimplemented, "an 'extension' can only extend a nominal type"); + if (!as(decl->targetType.type)) + { + getSink()->diagnose(decl->targetType.exp, Diagnostics::invalidExtensionOnType, decl->targetType); + } } void SemanticsDeclBasesVisitor::visitExtensionDecl(ExtensionDecl* decl) diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h index 059df4453..ff2775328 100644 --- a/source/slang/slang-diagnostic-defs.h +++ b/source/slang/slang-diagnostic-defs.h @@ -364,6 +364,9 @@ DIAGNOSTIC(30821, Error, tagTypeMustBeListedFirst, "an unum type may only have a DIAGNOSTIC(30820, Error, cannotInheritFromExplicitlySealedDeclarationInAnotherModule, "cannot inherit from type '$0' marked 'sealed' in module '$1'") DIAGNOSTIC(30821, Error, cannotInheritFromImplicitlySealedDeclarationInAnotherModule, "cannot inherit from type '$0' in module '$1' because it is implicitly 'sealed'; mark the base type 'open' to allow inheritance across modules") +DIAGNOSTIC(30822, Error, invalidTypeForInheritance, "type '$0' cannot be used for inheritance") + +DIAGNOSTIC(30850, Error, invalidExtensionOnType, "type '$0' cannot be extended. `extension` can only be used to extend a nominal type.") // 309xx: subscripts -- cgit v1.2.3