Open XAMPPRocky opened 1 month ago
Thank you for your suggestions. What information would you like to see in a meaningful compiler error? Pinpointing the exact location might not even need a lot of changes.
Apart from standard info like line number and spans. I think when designing the errors, the perspective should be "What does the user need to do to fix this?" for example right now this error doesn't tell what is failing to match, do I need fix a type name? It should point at exactly where the problem is and how it can be fixed, e.g. if it's a typo it should tell me whether there's something that closely matches the type name present.
Another thing that would help with this is adding snapshot testing that adds tests with known bad modules that test what different possible errors look like, that will make it a lot easier to prevent errors from regressing, and make it easy to see when a change improves an error message.
I like the idea of snapshot testing and I would like to get the rasn-compiler-test
there. As for matching errors, I made some improvements that should give users a better idea of where the problematic ASN1 is located in a module. I do not use a third-party crate for formatting at this point, because I wanted to defer adding another dependency until the next iteration of error improvements. I hope the changes provide some value. Also feel free to improve the error handling further.
The error output I get from this error doesn't really give me actionable information. I think it would be good to put some work in including more information to make errors more readable and accessible.
Two libraries that would help a lot here
Another alternative are the Chumsky/Ariadne combo which would require moving away from nom, but adding good errors might require extensive plumbing regardless.