Repository navigation
Conversation
Since Elixir 1.15, Code.eval_string/3 prints compiler diagnostics to stderr before raising CompileError, and the CompileError itself only says "cannot compile file (errors have been logged)". A failed evaluate, such as hovering over `defmodule` while paused, therefore sent the diagnostic to the client as a stderr output event and returned an evaluateError without the actual message. Each hover added another block to the debug console. Run the evaluation inside Code.with_diagnostics/1. When it raises CompileError, use the error diagnostics as the description, so the evaluateError carries the message instead of stderr. Other diagnostics, such as warnings, are still printed, now after the evaluation returns. Fixes elixir-lsp#1291
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1291
Since Elixir 1.15,
Code.eval_string/3prints compiler diagnostics to stderr before raisingCompileError, and the exception only sayscannot compile file (errors have been logged). So a failedevaluate(hovering overdefmodulewhile paused, for example) sent the diagnostic to the client as astderroutput event, once per hover, and theevaluateErrorit returned did not contain the actual message.evaluate_code_expression/3now runs insideCode.with_diagnostics/1:CompileError, the error diagnostics replace the exception's description, so the response starts with** (CompileError) lib/foo.ex: undefined variable "defmodule"and the error is not printed.Code.print_diagnostic/1, on success and on failure. They now come out after the evaluation returns rather than before it runs.Code.with_diagnostics/2frame is dropped from the reported stacktrace.This covers every
evaluatecontext (hover, watch, repl, clipboard). Conditional breakpoints, hit conditions and log points use the separateBreakpointConditionpath and still print diagnostics; there the printed diagnostic is the only place the error message appears, so I left it alone. Happy to fold it into their console message in a follow-up if you want.New tests in
debugger_test.exscover a compile error (message in the response, nothing on stderr), a compile error with a warning (only the warning printed) and a warning on a successful evaluate.