summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorMukund Keshava <mkeshava@nvidia.com>2025-06-02 12:14:23 +0530
committerGitHub <noreply@github.com>2025-06-02 06:44:23 +0000
commit359066147c0abc4ca6ad2902cc3a817383d4bd28 (patch)
tree15cbe9827678cc26ab8fba22e064c2d7a4631c32 /source
parent43f057f2ff68e11a028da6eb1827a51e2566f636 (diff)
move fix to CheckUsableType (#7264)
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-check-decl.cpp11
-rw-r--r--source/slang/slang-parser.cpp1
2 files changed, 2 insertions, 10 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index 081ccbb0b..5aff41988 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -10428,16 +10428,7 @@ void SemanticsDeclHeaderVisitor::visitAbstractStorageDeclCommon(ContainerDecl* d
void SemanticsDeclHeaderVisitor::visitSubscriptDecl(SubscriptDecl* decl)
{
- // __subscript needs to have a return type specified. Check if return type
- // is missing (represented as IncompleteExpr) and return an error.
- if (decl->returnType.exp && as<IncompleteExpr>(decl->returnType.exp))
- {
- getSink()->diagnose(decl, Diagnostics::subscriptMustHaveReturnType);
- }
- else if (decl->returnType.exp)
- {
- decl->returnType = CheckUsableType(decl->returnType, decl);
- }
+ decl->returnType = CheckUsableType(decl->returnType, decl);
visitAbstractStorageDeclCommon(decl);
diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp
index 439959827..398aab517 100644
--- a/source/slang/slang-parser.cpp
+++ b/source/slang/slang-parser.cpp
@@ -4110,6 +4110,7 @@ static NodeBase* parseSubscriptDecl(Parser* parser, void* /*userData*/)
}
else
{
+ parser->diagnose(decl->loc, Diagnostics::subscriptMustHaveReturnType);
decl->returnType.exp = parser->astBuilder->create<IncompleteExpr>();
}