Use ariadne error reporting library for compile errors#2426
Use ariadne error reporting library for compile errors#2426neunenak wants to merge 14 commits intocasey:masterfrom
Conversation
|
I deliberately introduced a compile error, here's what that looks like currently: and here's what that looks like with ariadne as it's currently set up in that PR: slightly nicer I suppose |
|
Is the formatting off in that error message? It looks misaligned. |
|
Tentatively, I think this looks good. This will be a massive change though, because there are so many tests which check error messages. I think the easiest way to do this would be to land a commit which switches to ariadne, but which doesn't change any error messages or try to add any additional highlights. I think we could write a script to automatically convert existing tests to the new format. Then we could start improving the error messages one by one, by adding additional spans, etc. Some questions:
|
This makes sense
Yeah. You have to do this in the kinda-silly way of defining
Yeah, that's totally optional. I kind of like the idea of having a rustc-style authoritative list of error codes, but that's not worth trying to merge in the first pass in any case.
Yeah there's an API for assigning pretty arbitrary colors to labels: |
Dope.
I like the idea of doing that too, although definitely later.
Dope. So yeah, I think this is a good change, although the search and replace for changing all the tests will be brutal. |
24538cd to
99b0305
Compare
4013357 to
5949274
Compare
|
An idea that might make this easier: Can we style the adriane errors so that they look the same as |
I'm not sure there's an easy way to make the error output look like just errors. I was having some trouble with tests not matching, which I realized was because ariadne was always emitting ansi color codes even in tests; so I added some functionality to pass color enable/disable to ariadne which solves that problem. Now it's just a matter of updating the tests, which I was trying to find a way to use an AI code editor to do. If not I'll write a script for it or do it manually. |
Update all integration test stderr expectations to match ariadne's output format, which uses '╭─[file:line:col]' and '───╯' instead of the previous '——▶' and '^^^^' format. Also remove unused `StrComparison` import from tests/test.rs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
db1ff03 to
d74eafc
Compare
Fix Report::build API change: the 3-argument form (kind, source_id, offset) is now 2-argument (kind, span) where span is (source_id, range). Update all test stderr expectations for the new format where the location is wrapped with spaces: `╭─[ file:line:col ]` instead of `╭─[file:line:col]`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When the max argument count is usize::MAX (representing no upper bound), display "takes at least N argument(s)" instead of the literal "takes between N and 18446744073709551615 arguments". Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace literal binary bytes (U+200B zero-width space and null byte) in
test source code with Rust escape sequences (\u{200b} and \0), making
tests/misc.rs a pure-ASCII file searchable by ripgrep and Neovim Telescope.
The escape sequences expand to the actual characters at runtime, so test
behavior is unchanged.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
96a7898 to
88e8c85
Compare
The Windows constant for the recursion limit error was still using the old `——▶` format. Update it to match ariadne's output format with the column number (57) where Windows hits the recursion limit due to its smaller default stack size. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@casey in the year or so since I last looked at this, LLMs got good enough to make the code changes in a (relatively) non-tedious way, so this PR is ready for review. |




This commit starts introducing the
ariadnerust error-reporting crate tojust. In order to make individual commits a bit more tractable, this commit only introduces the new ariadne error formatting for compile errors, leaving other sorts of errors alone for the time being.With the deliberately-broken justfile:
Running
justnow results in an error that looks like:This commit also updates the minimum rust version to 1.85, since the latest version of
ariadnealso requires that minimum version to compile; in the process of porting the tests, I also noticed that a couple of tests, namelyunknown_start_of_token_invisible_unicodeandunknown_start_of_token_ascii_control_char, had raw unprintable ascii literals in the source file, which was causing some problems with e.g. running ripgrep on the file containing them. So I changed them to use unicode escapes instead. Apart from this, all the tests should be exactly the same as they were previously, except for testing for the new error formatting.Pertains to #1323