Good error reporting in macro systems is tricky. An interesting Rust RFC to provide better messages:
miniblog.
Related Posts
Compiler error messages is such a deep topic. Even in rustc, a mature compiler that invests effort in diagnostic quality, I find interesting issues every few months.
(The majority have been fixed pretty quickly, so it's really rewarding to file issues.)
I've been using "Expected Int, but got String" for my type error messages, but I've been wondering if I could do better.
"Expected Int here, but this value has type String" or "This expression requires Int, but the value is String".
Do you have a favourite?
Some delightful examples of good compiler error messages in the latest Gleam release: