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: Omit type antecedents for unassigned variables #5877

Merged
merged 10 commits into from
Nov 6, 2024

Conversation

RustanLeino
Copy link
Collaborator

In let expressions and named function results, the bound variable was previously introduced with an assumption that the variable satisfied its type. That is not sound, since the type may be empty. This PR removes those premature type assumptions.

Fixes #1958

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

Copy link
Member

@MikaelMayer MikaelMayer left a comment

Choose a reason for hiding this comment

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

Looks like this PR does the job! Well done.

function Search4<T(==)>(s: seq<T>, x: T): (o: Option<int>)
ensures
o.Some? && o.value < |s| ==>
s[o.value] == x // error: ".value" may be negative
Copy link
Member

Choose a reason for hiding this comment

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

How does this function relates to the soundness issue being solved? Is that the baseline without subset types?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, that's the baseline -- just to make sure there's nothing else that causes the other tests to pass.

git-issue-1958.dfy(18,16): Error: value does not satisfy the subset constraints of 'R'
git-issue-1958.dfy(32,4): Error: value does not satisfy the subset constraints of 'R'
git-issue-1958.dfy(36,4): Error: value does not satisfy the subset constraints of 'R'
git-issue-1958.dfy(56,16): Error: function precondition could not be proved
Copy link
Member

Choose a reason for hiding this comment

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

That one, along with the one line 104, is not triggered on my machine and that's a soundness issue. So you fixed it !

@RustanLeino RustanLeino merged commit e815f23 into dafny-lang:master Nov 6, 2024
22 checks passed
@RustanLeino RustanLeino deleted the issue-1958 branch November 6, 2024 17:05
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.

Empty type of let variable assumed before binding
2 participants