From 15bff9162530113b426664eb0c1deb7ea9e3a90d Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Fri, 13 Apr 2018 13:36:26 -0700 Subject: Propagate diagnostics when imported module has errors (#485) A previous fix avoided crashes when an `import`ed module has errors by making the "failed to import" error a fatal one. Unfortunately, the code path that handles fatal errors was failing to copy diagnostic output from the sink over to the member variable on the `CompileRequest` that exposes the output through the API. This meant that API users lost all context on error messages in `import`ed code. This change fixes the immediate issue by plumbing through the error output, but doesn't fix the more fundamental issue: the front-end should not crash when an `import` fails, by any means. --- source/slang/slang.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/slang/slang.cpp') diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 5df180f46..dbd48753b 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -1120,6 +1120,10 @@ SLANG_API int spCompile( { // This should only be thrown if we already emitted a fatal error // message, so there is no reason to print something else. + // + // We still need to copy the diagnostic output into the variable + // that the user will query via the API. + req->mDiagnosticOutput = req->mSink.outputBuffer.ProduceString(); return 1; } catch (...) -- cgit v1.2.3