Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pretty manifest compiler error reporting #1741

Merged
merged 105 commits into from
Mar 22, 2024

Conversation

lrubasze
Copy link
Contributor

@lrubasze lrubasze commented Mar 15, 2024

Summary

This PR adds pretty compiler error reports for more clarity.
Examples:

image

or

image

Details

Chosen annotate-snippets crate to pretty print faulty manifest snippets.
There are also some other libs, but they are not maintained or are not widely adopted.
This crate is used by cargo, which was decisive argument to pick it up.
Each of the compiler errors: LexerError, ParserError, GeneratorError has its own error diagnostic function, which:

  • analyses the error
  • and prepares a manifest snippet accordingly

More ideas:

  • Add suggestions in the footer of the report, eg.
    invalid Ident specified 'CALL_METHODS', maybe you ment: 'CALL_METHOD'
  • provide more info basing on nested errors such as AddressBech32DecodeError or ParseNonFungibleLocalIdError
    instead of generic error message such as:
    error: invalid global address 'some_address'
  • prepare more precise message for aliases (eg. Bytes, Ok)
    we could print:
    error: expected value of type String, found Bytes (alias of Array)
    instead of:
    error: expected value of type String, found Array

Testing

Respective tests added.
Each test consist of 2 files:

  • *.rtm manifest file with some error
  • *.diag file with expected compiler output
    These files don't look good in Github, the best is to inspect them with cat command in terminal.
    Others use *.svg files, but I thought it's better to keep it simple.

Update Recommendations

For dApp Developers

Enjoy beautiful compiler error reports 🥂

For Internal Integrators

Maybe worth integrating with anything that uses raw manifest *.rtm files

Copy link
Contributor

@dhedey dhedey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice work! This is looking great. I love the attention to detail and clear error messages.

Most of my comments are minor suggestions/nitpicks, though there are one or two bugs that could be fixed too.

transaction/src/manifest/parser.rs Outdated Show resolved Hide resolved
transaction/src/manifest/parser.rs Outdated Show resolved Hide resolved
transaction/src/manifest/token.rs Outdated Show resolved Hide resolved
transaction/src/manifest/token.rs Outdated Show resolved Hide resolved
transaction/src/manifest/token.rs Outdated Show resolved Hide resolved
transaction/src/manifest/generator.rs Outdated Show resolved Hide resolved
transaction/src/manifest/generator.rs Outdated Show resolved Hide resolved
transaction/src/manifest/generator.rs Outdated Show resolved Hide resolved
transaction/src/manifest/generator.rs Outdated Show resolved Hide resolved
transaction/src/manifest/generator.rs Outdated Show resolved Hide resolved
@lrubasze lrubasze merged commit c30d901 into develop Mar 22, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants