summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com>2023-04-04 15:21:23 -0400
committerGitHub <noreply@github.com>2023-04-04 12:21:23 -0700
commit34a2fd593dd5a5d7b597b9d2fe20e39cc24b8e6c (patch)
tree8b87f9f5a74ca7e7c9da9b4cdefd8ff79f2a9ed2
parent206b546444b3e11d5059c4482ea2045132156e23 (diff)
Fix crash on encountering undefined identifier when checking derivative attributes (#2773)
* Fix compiler crash if referencing undefined method in the deriavative decorator * Delete sample.comp --------- Co-authored-by: Yong He <yonghe@outlook.com>
-rw-r--r--source/slang/slang-check-decl.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index 6a32f59d3..3ffb6c100 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -6923,15 +6923,18 @@ namespace Slang
auto ctx = visitor->withExprLocalScope(&scope);
auto subVisitor = SemanticsVisitor(ctx);
auto checkedFuncExpr = visitor->dispatchExpr(attr->funcExpr, ctx);
- visitor->ensureDecl(as<DeclRefExpr>(checkedFuncExpr)->declRef, DeclCheckState::TypesFullyResolved);
- auto invokeExpr = subVisitor.constructUncheckedInvokeExpr(checkedFuncExpr, imaginaryArguments);
- auto resolved = subVisitor.ResolveInvoke(invokeExpr);
- if (auto resolvedInvoke = as<InvokeExpr>(resolved))
+ if (auto derivFuncDeclRef = as<DeclRefExpr>(checkedFuncExpr)->declRef)
{
- if (auto calleeDeclRef = as<DeclRefExpr>(resolvedInvoke->functionExpr))
+ visitor->ensureDecl(derivFuncDeclRef, DeclCheckState::TypesFullyResolved);
+ auto invokeExpr = subVisitor.constructUncheckedInvokeExpr(checkedFuncExpr, imaginaryArguments);
+ auto resolved = subVisitor.ResolveInvoke(invokeExpr);
+ if (auto resolvedInvoke = as<InvokeExpr>(resolved))
{
- attr->funcExpr = calleeDeclRef;
- return;
+ if (auto calleeDeclRef = as<DeclRefExpr>(resolvedInvoke->functionExpr))
+ {
+ attr->funcExpr = calleeDeclRef;
+ return;
+ }
}
}
visitor->getSink()->diagnose(attr, Diagnostics::invalidCustomDerivative);