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

Report assertion errors at the assertion keyword #6012

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

keyboardDrummer
Copy link
Member

@keyboardDrummer keyboardDrummer commented Dec 31, 2024

What was changed?

When asserting a condition, do not use just condition's origin as an origin for that condition, but also the context in which it occurs. For example, let the origin be |e|nsures <expr> instead of <expr>, where the bars denote the center. This way, the origin for failing to prove the assertion is different than for failing to prove the condition's precondition, which is <expr>.

The most interesting changes are for calc statements. When the comparison between two expressions fails, the origin changes as follows. The | indicates the center and the ^s indicate the range.

Old:

  calc == {
    (x + y) * (x + y); 
    x * (x + y) + y * (x + y);
    ^^^^^^^^^^^^|^^^^^^^^^^^^
Error: the calculation step between the previous line and this line could not be proved

New:

  calc == {
    (x + y) * (x + y); 
    ^^^^^^^^^^^^^^^^^|
    x * (x + y) + y * (x + y);
    ^^^^^^^^^^^^^^^^^^^^^^^^^
Error: this calculation step could not be proved

When there is an explicit operator, it is used as the center:

  calc {
    (x + y) * (x + y);
    ^^^^^^^^^^^^^^^^^^
    ==
    |^
    x * (x + y) + y * (x + y);
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: this calculation step could not be proved

How has this been tested?

  • Updated existing tests

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@keyboardDrummer keyboardDrummer changed the title Tweak origins used for reporting assertion errors Report assertion errors at the assertion keyword Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant