-
Notifications
You must be signed in to change notification settings - Fork 170
Diagnostic messages: Fixing bugs and improving printing #398
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
Comments
Another one to fix: % lpython --show-asr integration_tests/test_builtin_pow.py --indent
Internal Compiler Error: Unhandled exception
Traceback (most recent call last):
File "/Users/namannimmo/Applications/oss/lpython/src/bin/lpython.cpp", line 755
return emit_asr(arg_file, runtime_library_dir,
File "/Users/namannimmo/Applications/oss/lpython/src/bin/lpython.cpp", line 180
std::cout << LFortran::pickle(*asr, compiler_options.use_colors, compiler_options.indent,
File "/Users/namannimmo/Applications/oss/lpython/src/lpython/pickle.cpp", line 90
return pickle((ASR::asr_t &)asr, colors, indent, show_intrinsic_modules);
File "/Users/namannimmo/Applications/oss/lpython/src/lpython/pickle.cpp", line 84
v.show_intrinsic_modules = show_intrinsic_modules;
File "/Users/namannimmo/Applications/oss/lpython/src/libasr/asr.h", line 2430
void visit_asr(const asr_t &b) { visit_asr_t(b, self()); }
File "/Users/namannimmo/Applications/oss/lpython/src/libasr/asr.h", line 2408
case asrType::unit: { v.visit_unit((const unit_t &)x); return; }
File "/Users/namannimmo/Applications/oss/lpython/src/libasr/asr.h", line 2431
void visit_unit(const unit_t &b) { visit_unit_t(b, self()); }
File "/Users/namannimmo/Applications/oss/lpython/src/libasr/asr.h", line 2263
switch (x.type) {
File "/Users/namannimmo/Applications/oss/lpython/src/libasr/asr.h", line 7600
for(int times = 0; times < tmp2; times++)
File "/Users/namannimmo/Applications/oss/lpython/src/libasr/asr.h", line 7537
LFORTRAN_ASSERT(indent_level >= 0);
AssertFailed: indent_level >= 0 FYI, this generates the ASR without |
Thanks for pointing it out, @namannimmo10! |
Another one: instead of this:
do this:
or even
or
|
Here is another one: #412 (comment) |
Does this design seems general? because this is looking specifically to the assignment. Moreover, looking into this, I see that we might also need to pass additional information in semantic errors to show this kind of error. |
Yes, the design is general (almost any message can be encoded), but the visualization of the diagnostic messages is not. |
Here is a new nice Rust library with more ideas how to visualize errors in a terminal: https://github.com/zesterer/ariadne (and see also https://github.com/zesterer/chumsky). |
Uh oh!
There was an error while loading. Please reload this page.
Now when we can test error/warning/hint messages (see
tests/errors
), we should work on improving how they are printed, and if we need any more information stored in theDiagnostics
class, we can do that too.Some bugs to fix:
Urgent improvements:
tests/errors
tests/errors
for errors to sample a wide variety of error messages, right now we have 9, I am thinking at least 30 to 50. Test tokenizer, parser, semantics (I can't think of a codegen error that is either not temporary or a bug in semantics, so we don't need to test those) --- then once we change how errors are printed, we can see the impact (just run./run_tests.py -u
) to make sure all corner cases still look good:Once these are fixed and tests added, we should work on good error messages, for example when you call a function
f(1, 2)
and some of the arguments don't agree, to highlight the declaration (possibly in different file), show where it was imported in the current file, show the expected type, show the current type, and so on.Other improvements:
--no-unicode-errors
will replace unicode characters with just ascii characters.~~~
and----
underlines, this should save vertical space. This must be optional, as you need to be able to see colors. With--no-color
we should still print underlines.Why to improve error messages
Already the diagnostic messages in LPython/LFortran are very good, but we have the opportunity to push this to (almost) perfection, we have the infrastructure, we have the ideas (see above), so we should just do it. Every user will sooner or later see these messages, and if they are beautiful, clear, to the point, it's a pleasure to see, and you want to see more of them: it's an art, it is like a nice painting that the compiler presents to the user, on top of their code. It will be one reason to use our compilers, to get these messages, because it makes the process of developing the code a pleasure.
The text was updated successfully, but these errors were encountered: