Skip to content

fix: Check for correct use of type characteristics in ghosts and default expressions - #4928

Merged
RustanLeino merged 21 commits into
dafny-lang:masterfrom
RustanLeino:fix-4926
Jan 22, 2024
Merged

RustanLeino merged 21 commits into
dafny-lang:masterfrom
RustanLeino:fix-4926

Conversation

@RustanLeino

Copy link
Copy Markdown
Collaborator

This PR adds checks for correct instantiations of type parameters that were previously missing. Previously, these checks were only done in non-ghost expressions (historically, it seems the code that performs these checks was designed for checking (==), which applies only in ghost expressions). This PR adds the checks also specifications (which are ghost) and default expressions for parameters).

The new test file git-issue-4926.dfy reports 38 errors, whereas before this PR, Dafny reported only 8.

It also extracts the code for these checks into a separate file, TypeCharacteristicChecker.cs (in addition to the existing file CheckTypeCharacteristics_Visitor).

Fixes #4926

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

keyboardDrummer
keyboardDrummer previously approved these changes Jan 3, 2024

@keyboardDrummer keyboardDrummer left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the refactoring as well ! Note it's easier to review if you put the code move into a separate commit.

@RustanLeino
RustanLeino enabled auto-merge (squash) January 9, 2024 17:48
# Conflicts:
#	Source/DafnyStandardLibraries/binaries/DafnyStandardLibraries-cs.doo
#	Source/DafnyStandardLibraries/binaries/DafnyStandardLibraries-go.doo
#	Source/DafnyStandardLibraries/binaries/DafnyStandardLibraries-java.doo
#	Source/DafnyStandardLibraries/binaries/DafnyStandardLibraries-js.doo
#	Source/DafnyStandardLibraries/binaries/DafnyStandardLibraries-notarget.doo
#	Source/DafnyStandardLibraries/binaries/DafnyStandardLibraries-py.doo
#	Source/DafnyStandardLibraries/binaries/DafnyStandardLibraries.doo
#	Source/DafnyStandardLibraries/src/Std/Collections/Seq.dfy
Comment thread docs/dev/news/4928.fix
@@ -0,0 +1 @@
Check for correct usage of type characteristics in specifications and other places where they were missing

@keyboardDrummer keyboardDrummer Jan 22, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If I understand correctly then this PR is a breaking change: it will cause Dafny to error in some locations where it previously did not. For example you had to update Source/DafnyStandardLibraries/src/Std/Collections/Array.dfy Might be good to note that in the release notes.

@RustanLeino
RustanLeino merged commit 47ab929 into dafny-lang:master Jan 22, 2024
RustanLeino added a commit that referenced this pull request Jan 27, 2024
Embellish release notes of PR #4928. The release note now try to make it
clear that any new errors (for this issue) on previous programs are
intentional.


<small>By submitting this pull request, I confirm that my contribution
is made under the terms of the [MIT
license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
@RustanLeino
RustanLeino deleted the fix-4926 branch February 20, 2024 18:01
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.

Missing (!new) check

3 participants