From 2e2c7943da89b0100db3bba4b11267b5a857ca92 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 20 Feb 2024 23:13:29 -0800 Subject: Language server robustness fix. (#3607) * Language server robustness fix. * Allow parameter name to be the same as its type. * fix * Fix test. --- source/slang/slang.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'source/slang/slang.cpp') diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 498dc67f5..a1627286d 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -3302,22 +3302,33 @@ RefPtr Linkage::loadModule( return nullptr; } - loadParsedModule( - frontEndReq, - translationUnit, - name, - filePathInfo); - + try + { + loadParsedModule( + frontEndReq, + translationUnit, + name, + filePathInfo); + } + catch (const Slang::AbortCompilationException&) + { + // Something is fatally wrong, we should return nullptr. + module = nullptr; + } errorCountAfter = sink->getErrorCount(); if (errorCountAfter != errorCountBefore && !isInLanguageServer()) { + // If something is fatally wrong, we want to report + // the diagnostic even if we are in language server + // and processing a different module. _diagnoseErrorInImportedModule(sink); // Something went wrong during the parsing, so we should bail out. return nullptr; } - module->setPathInfo(filePathInfo); + if (module) + module->setPathInfo(filePathInfo); return module; } -- cgit v1.2.3