-
Notifications
You must be signed in to change notification settings - Fork 704
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
Print a warning when assertions are enabled #8240
Conversation
Ideally, we'd distribute alpha versions with a subset of assertions enabled (and enable them for dev builds by default, which probably means all builds from repo source --- do we do that already?), but that would require more than |
The expensive assertions message is not printed cause the flag and the cpp was moved to cabal-solver after the original pr. |
I'd find the more precise warning helpful, but then I'm an assertions aficionado. |
Specific warning restored:
|
@grayjay respectful ping, I think you could be interested in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating #4552!
cabal-install/cabal-install.cabal
Outdated
flag debug-expensive-assertions | ||
description: Enable expensive assertions for testing or debugging | ||
default: False | ||
manual: True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand the purpose of this flag. It looks like it is independent of the one in the solver package, so the warning in this PR doesn't indicate whether the slow functions in the solver are enabled. I don't think that there is a way to make the cabal-install and solver packages share one CPP option, so Main.hs would probably need to call expensiveAssert directly and check for an exception, similarly to how it calls assert
.
I also think that it would be fine to leave out the warning about expensive assertions, because they are difficult to enable unintentionally. When I added the flag in #4346, I only intended for it to be enabled in one CI job, in order to check the assertions in tests. I think that the expensive assertions are slow enough that developers wouldn't want to enable them regularly when solving for install plans involving Hackage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, the cabal flag must have been split when cabal-install and cabal-install-solver had been split. I guess we (may in the future) use the flag in both, but we should treat them separately, alas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But, as @jneira remarks, using the flag and warning about the flag is a different thing, so I'm OK with simplifying.
changelog.d/pr-8240
Outdated
description: { | ||
|
||
- Now cabal-install executable will print a warning if assertions are enabled | ||
- The message will mention specifically the us of expensive assertions (currently present only in Cabal-solver) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/us/use/
hmm I thought if the flag name matches all local packages would be parametrized by |
The flags can be specified independently, as in
I think it is much more important to warn about enabling regular assertions, because they are useful in more situations, and it is easier to enable them accidentally. Additionally, even if you revert the part that handles expensive assertions, there will still be a warning whenever they are enabled, since they also require regular assertions to be enabled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Warning updated by |
I want to remember sometimes cabal builds with assetions enabled were leaked to final users.
Anyways i think warn about it would be useful for the reasons noted in #4377
Not sure how could this be tested without build a cabal version with assertions enabled and not sure it it worths it
Please include the following checklist in your PR:
Please also shortly describe how you tested your change. Bonus points for added tests!