I am happy to announce asai 0.2.0 for generating and printing compiler diagnostics. This is a major release: there are many improvements and (unfortunately) many backward-incompatible changes. Compared to the previous release, this version is significantly more stable, though we might still make big changes before 1.0.0. We have a quickstart tutorial for you to try out and would love to hear your feedback. The GitHub repository is at GitHub - RedPRL/asai: π©Ί A library for compiler diagnostics.
The most significant change is the introduction of structured reporters. The library can thus be used in two different modes:
- Use Reporter (as the old Logger): its API is biased towards free-form explanations.
- Use StructuredReporter: its API is biased towards fully structured messages.
Both modes share the same type of diagnostics, and thus, an application using structured messages can adopt a library using free-form explanations and vice versa. Great care has been taken to make sure the two modes can work together. The current tutorial focuses on Reporter and free-form explanations because that mode is slightly easier to set up.
The second most significant change is that the TTY handler got an overhaul. The output is now more concise, informational, and beautiful. You can trivially produce an error message like this:
In case you are wondering, we intentionally did not implement the Rust-style ASCII art due to our obsession with Unicode emojis (see our design philosophy). However, our modular design makes it is very easy to connect our message reporting interface with other rendering libraries, for example the one tracked by this GitHub issue. (The author said we should wait a bit before they finish the renderer, and thatβs why we have not implemented it yet!)
Thanks to @viritrilbia for many valuable suggestions.
Changelog
BREAKING CHANGES
- Span is renamed to Range
- Logger is renamed to Reporter and Reporter.Code is renamed to Reporter.Message
- Range: the type
position
was changed to allow string (in-memory) sources - Diagnostic: the type
diagnostic
was changed andmessage
was renamed toloctext
- The LSP handler is separated out as a new package (not published yet)