summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-check-expr.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-06-27 15:36:00 -0700
committerGitHub <noreply@github.com>2022-06-27 15:36:00 -0700
commitb7638b8fffe78ade657f361cadc08dffc8c10acf (patch)
treee27a141cfc6a9cc77356b8cba27b41c495d4ee27 /source/slang/slang-check-expr.cpp
parent62d16a23b0ecd72dc624abd7e10b373c40adaa90 (diff)
Language server fixes and improvements (#2304)
* Language server: Inlay hints. * Signature help for base exprs that is not a declref. * Fix checking of jvp operator. * Fix. * Add clang-format based auto formatting. * Fix clang error. * Fix clang-format discovery logic. * Fine tune auto formatting and completion experience. * Update macos workflow. * Fixes to configurations. * Fix parser recovery to trigger completion for index exprs. * Typo fix. Co-authored-by: Yong He <yhe@nvidia.com>
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;