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: Ability to cast a datatype to its trait when overriding functions #4824

Merged
merged 53 commits into from
Apr 1, 2024

Conversation

MikaelMayer
Copy link
Member

@MikaelMayer MikaelMayer commented Nov 28, 2023

This PR fixes #4823 (but not #4982 yet)

There were two issues there:

  • The function override check was casting to ClassLikeDecl, when it should now be TopLevelDeclWithMembers as IndDatatypeDecl can also override trait declarations.
  • The generated axiom used to rely on types being unboxed, but since now we might compare a trait with a datatype value, we need to ensure correct boxing for Boogie to type-check.
    I added the corresponding test.

I also ensured that the generation of doo files only use \n lines when creating the source (fixes #4989)

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

Copy link
Collaborator

@RustanLeino RustanLeino left a comment

Choose a reason for hiding this comment

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

Looks good, except for the unused declared of Cutoff.

@@ -569,6 +569,8 @@ public partial class BoogieGenerator {
}
}

private int Cutoff = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems this field is not used.

RustanLeino
RustanLeino previously approved these changes Dec 14, 2023
@MikaelMayer MikaelMayer enabled auto-merge (squash) December 14, 2023 20:08
MikaelMayer and others added 13 commits January 17, 2024 11:47
# Conflicts:
#	Source/DafnyCore/Verifier/BoogieGenerator.Functions.cs
#	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
# 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/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Fuel.legacy.dfy.expect
Copy link
Collaborator

@RustanLeino RustanLeino left a comment

Choose a reason for hiding this comment

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

It seems issue 4823 was fixed between Dafny 4.4 and 4.5.

@MikaelMayer MikaelMayer merged commit 10b59f5 into master Apr 1, 2024
20 checks passed
@MikaelMayer MikaelMayer deleted the fix-4823-general-traits-bug-extends branch April 1, 2024 20:21
@MikaelMayer
Copy link
Member Author

Indeed! The fix itself I had originally published got ousted in the merge commit, but at least this PR adds a test.

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.

Can't rebuild standard library files on Windows New type system refresh issue
4 participants