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

Print diagnostics in each interactive loop #2809

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/bin/lpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,8 @@ int interactive_python_repl(
res = fe.evaluate(code_string, verbose, lm, pass_manager, diagnostics);
if (res.ok) {
r = res.result;
std::cerr << diagnostics.render(lm, compiler_options);
diagnostics.clear();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, I think this approach is good to print style info/warnings. But for printing errors (semantic errors like in #2757), we should fix the python_ast_to_asr to return the result as not ok (that is res.ok = False).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a new issue for this here #2810. I think this PR is good to merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this as well. The reason is that for the intrinsic functions, we used append_error instead of throwing a semantic error. This could potentially be resolved by throwing the error later from python_ast_to_asr if the intrinsic function returns null.

} else {
LCOMPILERS_ASSERT(diagnostics.has_error())
std::cerr << diagnostics.render(lm, compiler_options);
Expand Down
Loading