fix(noirc_driver): Move error printing into nargo #1598
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Problem*
Resolves #1537
Summary*
This refactors
noirc_driver
functions to returnVec<FileDiagnostic>
if there is a problem compiling. The error reporter calls are then moved intonargo_cli
since that is the only place we'd want them reported on stderr.These changes make it possible for the LSP server to compile a file and send diagnostics back to the client (ref #1584).
I wasn't super happy to return non-Error types in the
Err
of the result, but I also don't think that these make sense to be an error, since we have to use a custom reporter to display them. I'm open to suggestions on how to clean this up.Additional work:
impl From
because it made converting between diagnostics/RuntimeError nicer.try_vecmap
because it bails at the first error, but we want to collect all of the FileDiagnostic errors that could occur and then only return a successful result it the errors are empty.file_manager()
function toDriver
so I could get a reference to the internal file manager. This isn't great and the FileManager should instead be controlled by Nargo and passed by reference to the driver. I'll open an issue for this.unwrap_or_else
calls in the wasm crate to use expect. Theunwrap_or_else
doesn't work consistently when I switched an API to Option instead of Result and expect does the exact same thing.Documentation
This PR requires documentation updates when merged.
Additional Context
PR Checklist*
cargo fmt
on default settings.