librasn / compiler

An ASN1 compiler producing Rust bindings for the rasn framework
Other
13 stars 7 forks source link

MatchingError output is confusing #50

Open XAMPPRocky opened 1 month ago

XAMPPRocky commented 1 month ago

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.


Rasn compiler error:
Encountered error while parsing MatchingError(Tag) - Error matching ASN syntax at while parsing: CA-ParametersNR-v1700 ::= SEQUENCE {
  -- R1 23-9-1: Basic Features of Further Enhanced Port-Selection Type II Codebook (FeType-II) per band combination information
    codebookParametersfetype2PerBC-r17               CodebookParametersfetype2PerBC-r17           OPTIONAL,
  -- R4 18-4: Support of e

6d7a commented 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.

XAMPPRocky commented 1 month ago

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.

XAMPPRocky commented 4 weeks ago

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.