From 34a2fd593dd5a5d7b597b9d2fe20e39cc24b8e6c Mon Sep 17 00:00:00 2001 From: Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> Date: Tue, 4 Apr 2023 15:21:23 -0400 Subject: 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 --- source/slang/slang-check-decl.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'source') 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(checkedFuncExpr)->declRef, DeclCheckState::TypesFullyResolved); - auto invokeExpr = subVisitor.constructUncheckedInvokeExpr(checkedFuncExpr, imaginaryArguments); - auto resolved = subVisitor.ResolveInvoke(invokeExpr); - if (auto resolvedInvoke = as(resolved)) + if (auto derivFuncDeclRef = as(checkedFuncExpr)->declRef) { - if (auto calleeDeclRef = as(resolvedInvoke->functionExpr)) + visitor->ensureDecl(derivFuncDeclRef, DeclCheckState::TypesFullyResolved); + auto invokeExpr = subVisitor.constructUncheckedInvokeExpr(checkedFuncExpr, imaginaryArguments); + auto resolved = subVisitor.ResolveInvoke(invokeExpr); + if (auto resolvedInvoke = as(resolved)) { - attr->funcExpr = calleeDeclRef; - return; + if (auto calleeDeclRef = as(resolvedInvoke->functionExpr)) + { + attr->funcExpr = calleeDeclRef; + return; + } } } visitor->getSink()->diagnose(attr, Diagnostics::invalidCustomDerivative); -- cgit v1.2.3