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: Wording of assertion failure closer to semantics #3324

Open
wants to merge 46 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
8e7320a
Fix: Wording of assertion failure to match what happens
MikaelMayer Jan 4, 2023
7acc626
Merge branch 'master' into fix-3216-could-not-prove
MikaelMayer Jan 4, 2023
3a1231e
Fixed case for "Could not"
MikaelMayer Jan 4, 2023
edaefcc
Merge branch 'fix-3216-could-not-prove' of https://github.com/dafny-l…
MikaelMayer Jan 4, 2023
174e304
Lowercase
MikaelMayer Jan 4, 2023
4350bcd
Passive voice so that important stuff is at the beginning
MikaelMayer Jan 4, 2023
83395c3
Review comments
MikaelMayer Jan 5, 2023
ec1d2e6
Review comments
MikaelMayer Jan 5, 2023
a237a0e
Merge branch 'master' into fix-3216-could-not-prove
MikaelMayer Jan 5, 2023
38568ae
Feat: Better format in hover messages
MikaelMayer Mar 3, 2023
c3c5516
Support for {:error} on hover also on postconditions
MikaelMayer Mar 4, 2023
32cb31d
Review comments
MikaelMayer Mar 6, 2023
05227f6
Review comments: Got rid of patches by integrating better with Proof …
MikaelMayer Mar 6, 2023
60ec8d9
Merge branch 'master' into feat-better-error-messages
MikaelMayer Mar 6, 2023
0aac9fe
Merge branch 'master' into feat-better-error-messages
MikaelMayer Mar 7, 2023
b136d48
Merge branch 'master' into feat-better-error-messages
MikaelMayer Mar 7, 2023
8d2b241
Merge branch 'master' into feat-better-error-messages
MikaelMayer Mar 8, 2023
b831daa
Fixed CI
MikaelMayer Mar 8, 2023
d7a32d3
Ensured EnsuresDescription and PostconditionDescription share relevan…
MikaelMayer Mar 8, 2023
be50afe
Ensure test is deterministic
MikaelMayer Mar 8, 2023
8876a81
Merge branch 'master' into feat-better-error-messages
MikaelMayer Mar 9, 2023
0cd8767
Merge branch 'master' into feat-better-error-messages
MikaelMayer Mar 10, 2023
89daeb4
Merge branch 'master' into feat-better-error-messages
MikaelMayer Mar 10, 2023
9d8d505
Merge branch 'master' into feat-better-error-messages
MikaelMayer Mar 10, 2023
ab390c5
Merge branch 'master' into feat-better-error-messages
MikaelMayer Mar 13, 2023
62abf54
Last review comment
MikaelMayer Mar 13, 2023
fea8f29
Merge remote-tracking branch 'origin/feat-better-error-messages' into…
MikaelMayer Mar 13, 2023
dcbd72f
Fixed latest merge.
MikaelMayer Mar 13, 2023
983ce45
Merge branch 'feat-better-error-messages' into fix-3216-could-not-prove
MikaelMayer Mar 14, 2023
8e35c5d
Fixed the merge
MikaelMayer Mar 14, 2023
fca2d6d
Merge branch 'master' into fix-3216-could-not-prove
MikaelMayer Mar 15, 2023
f044fc7
Removed entirely "might not" and replaced it with "could not be prove…
MikaelMayer Mar 16, 2023
88dfa58
Merge branch 'master' into fix-3216-could-not-prove
MikaelMayer Mar 16, 2023
aaafad6
proven => proved like in Boogie
MikaelMayer Mar 17, 2023
9c9afeb
be proven => be proved entirely
MikaelMayer Mar 17, 2023
d411ac8
Fixing upcoming merge
MikaelMayer Mar 17, 2023
df5e881
Merge branch 'master' into fix-3216-could-not-prove
MikaelMayer Mar 17, 2023
e4dea43
Removed unwanted files
MikaelMayer Mar 17, 2023
1fbee86
Removed wrongly committed project
MikaelMayer Mar 17, 2023
a70687b
Removed unused files
MikaelMayer Mar 17, 2023
a7744cb
Merge branch 'master' into fix-3216-could-not-prove
MikaelMayer Aug 17, 2023
3adc15b
Updated
MikaelMayer Aug 17, 2023
3796277
Merge branch 'master' into fix-3216-could-not-prove
MikaelMayer Aug 18, 2023
9974106
Merge branch 'master' into fix-3216-could-not-prove
MikaelMayer Jan 24, 2025
172ae09
Fixed the build
MikaelMayer Jan 24, 2025
c299831
Updating 30 tests
MikaelMayer Jan 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Source/DafnyCore/Verifier/ProofObligationDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public abstract class ProofObligationDescription : Boogie.ProofObligationDescrip

public class DivisorNonZero : ProofObligationDescription {
public override string SuccessDescription =>
"divisor is always non-zero.";
"divisor is always non-zero";

public override string FailureDescription =>
"possible division by zero";
Expand Down Expand Up @@ -279,7 +279,7 @@ customErrMsg is null
: $"error is impossible: {customErrMsg}";

public override string FailureDescription =>
customErrMsg ?? "function precondition might not hold";
customErrMsg ?? "function precondition could not be proven";

public override string ShortDescription => "precondition";

Expand All @@ -297,7 +297,7 @@ customErrMsg is null
: $"error is impossible: {customErrMsg}";

public override string FailureDescription =>
customErrMsg ?? "assertion might not hold";
customErrMsg ?? "assertion could not be proven";

public override string ShortDescription => "assert statement";

Expand Down Expand Up @@ -331,7 +331,7 @@ public class CalculationStep : ProofObligationDescription {
"the calculation step between the previous line and this line always holds";

public override string FailureDescription =>
"the calculation step between the previous line and this line might not hold";
"the calculation step between the previous line and this line could not be proven";

public override string ShortDescription => "calc step";
}
Expand Down
4 changes: 2 additions & 2 deletions Source/DafnyCore/Verifier/Translator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7233,7 +7233,7 @@ Bpl.Ensures Ensures(IToken tok, bool free, Bpl.Expr condition, string errorMessa
Contract.Ensures(Contract.Result<Bpl.Ensures>() != null);

Bpl.Ensures ens = new Bpl.Ensures(ForceCheckToken.Unwrap(tok), free, condition, comment);
ens.Description = new PODesc.AssertStatement(errorMessage ?? "This is the postcondition that might not hold.");
ens.Description = new PODesc.AssertStatement(errorMessage ?? "this is the postcondition that could not be proven.");
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you are going with the lower case style, then remove the ending periods as well

Copy link
Member

Choose a reason for hiding this comment

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

It is usually in a full sentence, though, of the form "Error: here is something in lowercase."

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, but the style in dafny elsewhere is predominantly to start with lower-case and not have a period, except when there are clearly multiple sentences. I'm not wedded to this style, and am open to a team discussion, but I'd like it to be consistent.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, good point. I'm fine with leaving out the periods.

return ens;
}

Expand All @@ -7242,7 +7242,7 @@ Bpl.Requires Requires(IToken tok, bool free, Bpl.Expr condition, string errorMes
Contract.Requires(condition != null);
Contract.Ensures(Contract.Result<Bpl.Requires>() != null);
Bpl.Requires req = new Bpl.Requires(ForceCheckToken.Unwrap(tok), free, condition, comment);
req.Description = new PODesc.AssertStatement(errorMessage ?? "This is the precondition that might not hold.");
req.Description = new PODesc.AssertStatement(errorMessage ?? "this is the precondition that could not be proven");
return req;
}

Expand Down
10 changes: 5 additions & 5 deletions Source/DafnyLanguageServer.Test/Lookup/HoverVerificationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ method Abs(x: int) returns (y: int)
", "testFile.dfy");
// When hovering the postcondition, it should display the position of the failing path
await AssertHoverMatches(documentItem, (2, 15),
@"[**Error:**](???) This postcondition might not hold on a return path.
@"[**Error:**](???) this postcondition could not be proven on a return path
This is assertion #1 of 4 in method Abs
Resource usage: ??? RU
Return path: testFile.dfy(6, 5)"
);
// When hovering the failing path, it does not display the position of the failing postcondition
// because the IDE extension already does it.
await AssertHoverMatches(documentItem, (5, 4),
@"[**Error:**](???) A postcondition might not hold on this return path.
@"[**Error:**](???) a postcondition could not be proven on this return path
This is assertion #1 of 4 in method Abs
Resource usage: ??? RU"
);
await AssertHoverMatches(documentItem, (7, 11),
@"[**Error:**](???) assertion might not hold
@"[**Error:**](???) assertion could not be proven
This is assertion #2 of 4 in method Abs
Resource usage: 9K RU"
);
Expand All @@ -86,7 +86,7 @@ await SetUp(o => {
}
", "testfile.dfy");
await AssertHoverMatches(documentItem, (1, 12),
@"[**Error:**](???) assertion might not hold
@"[**Error:**](???) assertion could not be proven
This is the only assertion in [batch](???) #??? of ??? in method f
[Batch](???) #??? resource usage: ??? RU"
);
Expand Down Expand Up @@ -123,7 +123,7 @@ await AssertHoverMatches(documentItem, (2, 12),
[Batch](???) #1 resource usage: ??? RU"
);
await AssertHoverMatches(documentItem, (3, 26),
@"[**Error:**](???) assertion might not hold
@"[**Error:**](???) assertion could not be proven
This is assertion #1 of 2 in [batch](???) #2 of 2 in function f
[Batch](???) #2 resource usage: ??? RU"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ decreases y
Assert.AreEqual(DiagnosticSeverity.Error, diagnostics[1].Severity);
Assert.AreEqual(1, diagnostics[0].RelatedInformation.Count());
var relatedInformation = diagnostics[0].RelatedInformation.First();
Assert.AreEqual("This postcondition might not hold: product >= 0", relatedInformation.Message);
Assert.AreEqual("this postcondition could not be proven: product >= 0", relatedInformation.Message);
Assert.AreEqual(new Range(new Position(2, 30), new Position(2, 42)), relatedInformation.Location.Range);
await AssertNoDiagnosticsAreComing(CancellationToken);
}
Expand Down Expand Up @@ -666,9 +666,9 @@ modifies this
Assert.AreEqual(DiagnosticSeverity.Error, diagnostics[0].Severity);
var relatedInformation = diagnostics[0].RelatedInformation.ToArray();
Assert.AreEqual(2, relatedInformation.Length);
Assert.AreEqual("This postcondition might not hold: Valid()", relatedInformation[0].Message);
Assert.AreEqual("this postcondition could not be proven: Valid()", relatedInformation[0].Message);
Assert.AreEqual(new Range((14, 16), (14, 23)), relatedInformation[0].Location.Range);
Assert.AreEqual("Could not prove: b < c", relatedInformation[1].Message);
Assert.AreEqual("could not prove: b < c", relatedInformation[1].Message);
Assert.AreEqual(new Range((9, 11), (9, 16)), relatedInformation[1].Location.Range);
await AssertNoDiagnosticsAreComing(CancellationToken);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ DidChangeTextDocumentParams MakeChange(int? version, Range range, string text) {
Assert.IsNotNull(document);
Assert.AreEqual(documentItem.Version + 11, document.Version);
Assert.AreEqual(1, document.Diagnostics.Count());
Assert.AreEqual("assertion might not hold", document.Diagnostics.First().Message);
Assert.AreEqual("assertion could not be proven", document.Diagnostics.First().Message);
}

[TestMethod, Timeout(MaxTestExecutionTimeMs)]
Expand Down
2 changes: 1 addition & 1 deletion Source/DafnyLanguageServer/Handlers/DafnyHoverHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ string GetDescription(Boogie.ProofObligationDescription? description) {
if (currentlyHoveringPostcondition &&
(failureDescription == new PostconditionDescription().FailureDescription ||
failureDescription == new EnsuresDescription().FailureDescription)) {
failureDescription = "This postcondition might not hold on a return path.";
failureDescription = "this postcondition could not be proven on a return path";
}
return $"{obsolescence}[**Error:**](https://dafny-lang.github.io/dafny/DafnyRef/DafnyRef#sec-verification-debugging) " +
failureDescription;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void ReportBoogieError(ErrorInformation error) {
private readonly string entryDocumentsource;

public static string FormatRelated(string related) {
return $"Could not prove: {related}";
return $"could not prove: {related}";
}

private IEnumerable<DiagnosticRelatedInformation> CreateDiagnosticRelatedInformationFor(IToken token, string message) {
Expand All @@ -93,7 +93,7 @@ private IEnumerable<DiagnosticRelatedInformation> CreateDiagnosticRelatedInforma
var rangeLength = range.EndToken.pos + range.EndToken.val.Length - range.StartToken.pos;
if (message == PostConditionFailingMessage) {
var postcondition = entryDocumentsource.Substring(range.StartToken.pos, rangeLength);
message = $"This postcondition might not hold: {postcondition}";
message = $"this postcondition could not be proven: {postcondition}";
} else if (message == "Related location") {
var tokenUri = tokenForMessage.GetDocumentUri();
if (tokenUri == entryDocumentUri) {
Expand Down
Loading