From b7638b8fffe78ade657f361cadc08dffc8c10acf Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 27 Jun 2022 15:36:00 -0700 Subject: 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 --- source/slang/slang-check-expr.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'source/slang/slang-check-expr.cpp') 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(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(); // 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(expr->baseFunction->type)) + { + getSink()->diagnose(expr->baseFunction->loc, Diagnostics::expectedFunction, expr->baseFunction->type); + } } return expr; -- cgit v1.2.3