Skip to content

Add assert messages and print bad argument values in asserts#5216

Merged
lucasmerlin merged 5 commits intoemilk:masterfrom
bircni:patch17
Mar 25, 2025
Merged

Add assert messages and print bad argument values in asserts#5216
lucasmerlin merged 5 commits intoemilk:masterfrom
bircni:patch17

Conversation

@bircni
Copy link
Copy Markdown
Contributor

@bircni bircni commented Oct 2, 2024

Enabled the missing_assert_message lint

  • I have followed the instructions in the PR template

@github-actions
Copy link
Copy Markdown

github-actions bot commented Oct 2, 2024

Preview available at https://egui-pr-preview.github.io/pr/5216-patch17
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

@bircni bircni marked this pull request as ready for review October 2, 2024 19:58
@bircni
Copy link
Copy Markdown
Contributor Author

bircni commented Dec 2, 2024

@lucasmerlin could you have a look at it?

Copy link
Copy Markdown
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

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

Thanks for working on this (and sorry for the slow review). I think if we do this we should go all the way and also include printing the bad argument value (where it makes sense).

debug_assert!(desired_size.x >= 0.0 && desired_size.y >= 0.0);
debug_assert!(
desired_size.x >= 0.0 && desired_size.y >= 0.0,
"desired_size should be positive"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Most of these would be a lot more useful if we printed the value that was wrong:

Suggested change
"desired_size should be positive"
"desired_size should be positive, got {desired_size:?}"

here and (almost) everywhere

@bircni bircni reopened this Mar 21, 2025
@bircni
Copy link
Copy Markdown
Contributor Author

bircni commented Mar 21, 2025

@emilk restarted the PR

Copy link
Copy Markdown
Collaborator

@lucasmerlin lucasmerlin left a comment

Choose a reason for hiding this comment

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

Awesome, thank you for re-doing this!

@lucasmerlin lucasmerlin added eframe Relates to epi and eframe egui emath Relates to the emath crate dev-experience epaint and removed eframe Relates to epi and eframe labels Mar 25, 2025
@lucasmerlin lucasmerlin changed the title enable missing_assert_message lint Add assert messages and print bad argument values in asserts Mar 25, 2025
bircni and others added 4 commits March 25, 2025 09:10
Co-authored-by: Lucas Meurer <[email protected]>
Co-authored-by: Lucas Meurer <[email protected]>
Co-authored-by: Lucas Meurer <[email protected]>
Co-authored-by: Lucas Meurer <[email protected]>
@bircni
Copy link
Copy Markdown
Contributor Author

bircni commented Mar 25, 2025

@lucasmerlin fixed the rest
Sorry missed some 😅

@lucasmerlin
Copy link
Copy Markdown
Collaborator

No worries!

@lucasmerlin lucasmerlin merged commit 58b2ac8 into emilk:master Mar 25, 2025
25 checks passed
darkwater pushed a commit to darkwater/egui that referenced this pull request Aug 24, 2025
)

Enabled the `missing_assert_message` lint

* [x] I have followed the instructions in the PR template

---------

Co-authored-by: Lucas Meurer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants