Critique my error messages! (Fennel)

I've recently put some work into adding friendly error messages to the compiler I work on for Fennel, which is a lisp. I have taken a cursory look at how Elm does compiler errors as it's arguably the best-in-class at this. Since Fennel does not have static types, it will never be able to provide as good feedback as Elm in the compiler, but it's much clearer than the old errors.

You can see a nearly-complete catalog here: https://p.hagelb.org/friendly.txt.html

I would love to hear suggestions of what could be improved. I'm considering adding multiple lines in the "problem pinpointing" but I don't have a great grasp of how to determine when multiple lines would be helpful.

Posted May 3, 2020, 11:00 PM UTC

165
Host127001•

Are you sure you want `unused variable` as an error instead of a warning? That might be bit annoying while prototyping.

Also just wondering, don't people like error messages that start with `<file>.<line>.<col>: `?

11
technomancyOP•

The unused variable one right now is only an error when you add a certain flag to the compiler, yeah. It's just included for completeness sake.

I've never seen any compiler that uses a dot instead of a colon for line numbers personally. But it's a good point that the current output is omitting the column number.

3
thefriedel•

Looks great so far, maybe you could add to your 'expected ...' an 'unexpected' sequence and don't mark one char with an ---^, just with a single ^, looks bit ugly and is confusing with other arrowless marks.

Also, multilines are useless and confusing, keep focus on important things, but you could moving the line number from the filename before the line, e. g. 14 | ... :)

6
o11c•

Always generate output compatible with GCC. That way, editors will be able to parse the file/line info out and jump to it (and also further information such as fixups).

Need note: to specify additional locations.

2
keeheth•

I'm not very familiar with Lisp, but these error messages look pretty promising. They explain what went wrong, give some more context, and offer suggestions for common fixes.

Might even be worth looking into how clang's errors work. They are a subset of GCC's, but they can contain "Fix me" messages, which basically are human and machine-readable descriptions of a way to fix an error. Many IDEs can parse those and will then offer a "Fix" button that automatically applies the change.

1