I am investigating how to design error messages in LFortran, a modern Fortran compiler that we are developing. Our goal is to have the state-of-the-art error messages. I knew Rust has excellent error messages, and learning about how they designed them:
they referenced Elm as an inspiration. So I read about how Elm designed it, I linked the blog posts in the above GitLab link (I can’t post more than 2 links as a new user). And I have a couple questions. It looks like there are slight differences in the Rust design vs Elm design:
- Elm seems to print the relevant source code (with just a simple span marker but no label), and then provide most information underneath, such as expected types and other hints
- Rust uses primary and secondary markers/spans and labels. The primary is in red, that’s typically the actual error, and then the secondary labels are in blue, and they always reference some spots in the code. They sometimes also print more info underneath if it does not fit the labels.
I noticed people on this Forum often use both Rust and Elm. Which style do you prefer? What are the pros/cons? Or are both equally good, just a personal taste?
Are there some parts that you would improve in Elm and/or Rust?
I agree with the Elm’s blog posts with the motivation for good error messages. My experience with using Rust a little bit is the opposite of a C++ compiler (especially the older ones). With C++ I am dreading to get any error messages. With Rust I am almost looking forward to have a conversation with the compiler. I haven’t used Elm beyond just playing in the online demo, but the error messages experience seems very similar. So both Elm and Rust are my gold standards so far when it comes to error messages.
P.S. I am hoping to figure out a similar “compiler assistant” approach for having back and forth with the compiler with regards to optimizations, how it rewrites the code. That is specific to Fortran, where performance of the numerical code is essential.