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

fix(sem): fix crash routine pragma redefinition #1445

Merged

Conversation

saem
Copy link
Collaborator

@saem saem commented Sep 3, 2024

Summary

The compiler no longer crashes when encountering a pragma redefinition
error on a routine. This was due to unnecessary asserts in error message
code

Details

  • dropped the asserts that added no value
  • dropped the redundancy in the error message itself, no need to repeat
    the symbol for the definition, as they will be the same
  • error message generation now properly uses string format ( % )
    instead of concatenation

Fixes #1444

error reporting

This existed because of unhelpful assertions in legacy reports.
fix code that was clowning instead of actually using string formatting

still not qutie right as there is _some_ flexibility with pragmas on
definitions
@saem saem added bug Something isn't working compiler/sem Related to semantic-analysis system of the compiler compiler/msgs Compiler output and diagnostic subsystem: error and warnig reporting, information, debugging labels Sep 3, 2024
@saem saem added this to the Diagnostics and error messages milestone Sep 3, 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. I left one minor suggestion regarding the test file placement.

(I believe you also want to update the PR title?)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Given that the test is for an error message, I think it would make sense to move it to the errmsgs category, but that's only a soft suggestion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I debated that, I think error messages should be part of the feature/functionality they're defining in the error case, where errmsgs is for stuff we can't otherwise categorize, but maybe that's not as wise an idea as I think it is.

Thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, from the top of my head, I'd consider there being an error part of the feature, while a test for the exact message(s) feels like something separate from it.

Following that line of though, in this case, completing a forward-declaration with a header using different pragmas being an error would belong under lang_callable, while a test for the message itself would belong under errmsgs.

Given that there's only a single message format here, there's no point in having two separate tests, so I think the current test location is correct. For ease of later test navigation/lookup, what you could do is add a error_message label to the test, but that's just another (very) soft suggestion.

compiler/front/cli_reporter.nim Outdated Show resolved Hide resolved
@saem saem changed the title Saem fix routine pragma redefinition crash fix(sem): routine pragma redefinition no longer crash Sep 3, 2024
@saem
Copy link
Collaborator Author

saem commented Sep 3, 2024

Looks good to me. I left one minor suggestion regarding the test file placement.

Thanks

(I believe you also want to update the PR title?)

Done

@saem saem changed the title fix(sem): routine pragma redefinition no longer crash fix(sem): fix crash routine pragma redefinition Sep 3, 2024
@saem
Copy link
Collaborator Author

saem commented Sep 3, 2024

/merge

Copy link

github-actions bot commented Sep 3, 2024

Merge requested by: @saem

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


Notes for Reviewers

  • I disabled the asserts because they add so little actual safety
  • I didn't fully change the message as pragmas are technically allowed to be repeated on definition as part of this PR to keep it a bit more focused

@chore-runner chore-runner bot added this pull request to the merge queue Sep 3, 2024
Merged via the queue into nim-works:devel with commit c587666 Sep 3, 2024
35 checks passed
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 compiler/sem Related to semantic-analysis system of the compiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash with mismatching pragmas in forward declaration
2 participants