summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-check-expr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-check-expr.cpp')
-rw-r--r--source/slang/slang-check-expr.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp
index 576220c02..df58b11ed 100644
--- a/source/slang/slang-check-expr.cpp
+++ b/source/slang/slang-check-expr.cpp
@@ -1514,13 +1514,14 @@ namespace Slang
// Check/Resolve inner function declaration.
expr->baseFunction = CheckTerm(expr->baseFunction);
+ auto astBuilder = this->getASTBuilder();
+
if(auto primalType = as<FuncType>(expr->baseFunction->type))
{
// Resolve JVP type here.
// Note that this type checking needs to be in sync with
// the auto-generation logic in slang-ir-jvp-diff.cpp
- auto astBuilder = this->getASTBuilder();
FuncType* jvpType = astBuilder->create<FuncType>();
// Only float types can be differentiated for now.
@@ -1529,9 +1530,12 @@ namespace Slang
// void otherwise.
//
if (primalType->resultType->equals(astBuilder->getFloatType()))
- jvpType->resultType = astBuilder->getFloatType();
- else
- jvpType->resultType = astBuilder->getVoidType();
+ jvpType->resultType = astBuilder->getFloatType();
+ else
+ {
+ //TODO(yong): issue proper diagnostic here.
+ jvpType->resultType = astBuilder->getVoidType();
+ }
// No support for differentiating function that throw errors, for now.
SLANG_ASSERT(primalType->errorType->equals(astBuilder->getBottomType()));
@@ -1553,7 +1557,11 @@ namespace Slang
else
{
// Error
- UNREACHABLE_RETURN(nullptr);
+ expr->type = astBuilder->getErrorType();
+ if (!as<ErrorType>(expr->baseFunction->type))
+ {
+ getSink()->diagnose(expr->baseFunction->loc, Diagnostics::expectedFunction, expr->baseFunction->type);
+ }
}
return expr;