Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle recoverable errors from SWC #500

Open
bartlomieju opened this issue Aug 29, 2020 · 8 comments
Open

Handle recoverable errors from SWC #500

bartlomieju opened this issue Aug 29, 2020 · 8 comments

Comments

@bartlomieju
Copy link
Member

Much like TSC, SWC can recover from number of errors during parsing. Currently we treat any error as terminal and don't proceed to work on AST.

Parser.take_errors() can be used to obtain recoverable errors.

This issue can be treated as an umbrella issue for dependency analysis, deno doc and deno lint.

CC @kdy1

@bartlomieju
Copy link
Member Author

After conversation with @kdy1 it turns out it's not really needed.

@bartlomieju
Copy link
Member Author

Actually after another conversation with @kdy1 we should look into this problem.

All parsing is done in cli/ast.rs in either parse() and transpile() functions. Currently when encountering error we always emit it using DiagnosticBuffer helper struct which converts SWC diagnostics into string errors. Due to this conversion we lose structured data from SWC's diagnostics which could potentially could be used to generate more descriptive errors. Additionally this conversion causes hard errors and terminates the execution and we never try to recover (recovery might not make sense in deno itself but it would be helpful in deno_lint which uses the same infrastructure).

@kdy1 can you look into this issue?

@kdy1
Copy link
Contributor

kdy1 commented Nov 3, 2020

It's okay to exit with failure on parsing error in deno because the parser does not do any linting - all errors are critical issue for compiler and runtime.
I mean, if runtime implements ecmascript specification correctly, it will be hard error anyway.

But as swc has rich diagnostic system (it's copied from rustc source code), I think converting diagnostics to string is not a good idea. It can have some annotations, suggestions, sub-diagnostics and / or multiple spans. Although errors from the parser is not, the error reporting system itself is rustc-grade.

@bartlomieju
Copy link
Member Author

@kdy1 then I guess it makes more sense to handle this problem in deno_lint first. I'm going to transfer the issue to deno_lint repo.

It also seems to to me that in case of linter we could transform SWC diagnostic in LintDiagnostic.

@bartlomieju bartlomieju transferred this issue from denoland/deno Nov 3, 2020
@kmurph73
Copy link

kmurph73 commented Dec 10, 2020

Just want to toss in a +1 for this issue. Constantly receiving the "A request has failed. See the output for more information." popup in VS Code is quite jarring (if this is in fact the root cause of that problem). Thank you.

@bartlomieju
Copy link
Member Author

@kmurph73 it looks like a vscode_deno error; can you open an issue there?

@kmurph73
Copy link

@bartlomieju thanks, just looked, and found that an issue already exists... denoland/vscode_deno#200

Looks like errors from deno.format just needs to be rescued? I can play around with the extension locally and create a PR tomorrow for that.

@bartlomieju
Copy link
Member Author

@bartlomieju thanks, just looked, and found that an issue already exists... denoland/vscode_deno#200

Looks like errors from deno.format just needs to be rescued? I can play around with the extension locally and create a PR tomorrow for that.

@kmurph73 extension undergoes a major refactor and this problem should be fixed soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants