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

Produce a meaningful error message for invalid module name #1354

Merged
merged 3 commits into from
Jun 19, 2024

Conversation

alaviss
Copy link
Contributor

@alaviss alaviss commented Jun 19, 2024

Summary

While the AST form of the error generated by modules/modulepaths is
handled in cli_reporter , the symbol form was not, creating terrible
error messages such as:

Error: invalid module name '<nil tree>'

This PR makes cli_reporter aware of the symbol form generated by
modules/modules , fixing the bad error message.

Details

  • cli_reporter now handles the symbol form of
    rsemInvalidModuleName correctly.
  • modules/modules now raises rsemInvalidModuleName with line
    information, allowing user and tools to know which file the error
    originated from.

Fixes #720

While the AST form of the error generated by `modules/modulepaths` is
handled, the symbol form was not, creating terrible error messages like:

    Error: invalid module name '<nil tree>'

This commit makes cli_reporter aware of the symbol form generated by
`modules/modules`, fixing the bad error message.
This allow us to test the error message with testament, as well as
giving the user a better idea as to which file is the culprit.
@zerbina zerbina self-requested a review June 19, 2024 14:16
@zerbina zerbina added bug Something isn't working compiler/sem Related to semantic-analysis system of the compiler labels Jun 19, 2024
Copy link
Collaborator

@zerbina zerbina left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you for reviving the fix!

I think the current description is okay as is, but for future PRs, especially those with a more outside-facing change (like this fix), could you focus the summary more on the user-facing changes? Along the lines of "this was the visible previous behaviour, this is how it behaves now", with the implementation details going into the "Details" section.

tests/errmsgs/tinvalid-name.nim Outdated Show resolved Hide resolved
@zerbina zerbina added compiler/msgs Compiler output and diagnostic subsystem: error and warnig reporting, information, debugging and removed compiler/sem Related to semantic-analysis system of the compiler labels Jun 19, 2024
@zerbina
Copy link
Collaborator

zerbina commented Jun 19, 2024

/merge

Copy link

Merge requested by: @zerbina

Contents after the first section break of the PR description has been removed and preserved below:


Notes for Reviewers

@chore-runner chore-runner bot added this pull request to the merge queue Jun 19, 2024
Merged via the queue into nim-works:devel with commit 6cfebd9 Jun 19, 2024
31 checks passed
@alaviss alaviss deleted the push-xvlzunqtvmlr branch June 19, 2024 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler/msgs Compiler output and diagnostic subsystem: error and warnig reporting, information, debugging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash when compiling a-b.nim
2 participants