Skip to content

Commit

Permalink
Merge branch 'master' into per-backend-code-support-in-stdlibs
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-aws authored Nov 16, 2023
2 parents 2488d76 + 1b89c34 commit 9366db9
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Source/DafnyCore/Generic/Reporting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ protected override bool MessageCore(MessageSource source, ErrorLevel level, stri
errorLine += "\n";
}

Options.OutputWriter.Write(errorLine);

if (Options.Get(DafnyConsolePrinter.ShowSnippets) && tok != Token.NoToken) {
TextWriter tw = new StringWriter();
new DafnyConsolePrinter(Options).WriteSourceCodeSnippet(tok.ToRange(), tw);
Options.OutputWriter.Write(tw.ToString());
}

Options.OutputWriter.Write(errorLine);

if (Options.OutputWriter == Console.Out) {
Console.ForegroundColor = previousColor;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
git-issue-3304.dfy(5,9): Error: the type of this expression is underspecified
|
5 | assert [] == [[]];
| ^

git-issue-3304.dfy(5,9): Error: the type of this expression is underspecified
1 resolution/type errors detected in git-issue-3304.dfy
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// RUN: %exits-with 4 %baredafny verify %args --warn-redundant-assumptions --warn-contradictory-assumptions --show-snippets:true "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

module M {
opaque function ToSet(xs: seq<int>): set<int> {
set x: int | x in xs
}

lemma LemmaCardinality(xs: seq<int>)
ensures |ToSet(xs)| <= |xs|
{}

lemma LemmaEmpty(xs: seq<int>)
requires xs == []
ensures |ToSet(xs)| == 0
{
assume false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
git-issue-4787.dfy(11,2): Error: a postcondition could not be proved on this return path
|
11 | {}
| ^

git-issue-4787.dfy(10,12): Related location: this is the postcondition that could not be proved
|
10 | ensures |ToSet(xs)| <= |xs|
| ^^^^^^^^^^^^^^^^^^^

git-issue-4787.dfy(15,12): Warning: ensures clause proved using contradictory assumptions
|
15 | ensures |ToSet(xs)| == 0
| ^^^^^^^^^^^^^^^^

git-issue-4787.dfy(14,13): Warning: unnecessary requires clause
|
14 | requires xs == []
| ^^^^^^^^


Dafny program verifier finished with 1 verified, 1 error
1 change: 1 addition & 0 deletions docs/dev/news/4787.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix error messages being printed after their context snippets

0 comments on commit 9366db9

Please sign in to comment.