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: Fix naming of formals in Translator #2266

Merged
merged 21 commits into from
Feb 1, 2023

Conversation

Dargones
Copy link
Collaborator

@Dargones Dargones commented Jun 16, 2022

Fixes #2263, which is due to inconsistent naming of formal parameters in automatically generated function handles.

Explanation: The syntax of MkTyParamFormals was changed with commit 81cf582 from

List<Bpl.Variable> MkTyParamFormals(List<TypeParameter> args, bool named = true)

to

List<Variable> MkTyParamFormals(List<TypeParameter> args, bool includeWhereClause, bool named = true)

But the call to the method on this line was left unchanged, so the method is now being called with named field set to the default true. Elsewhere the formal parameters of the a function handle don't get a name. The result is a mix-match of named and unnamed formals that causes the bug reported in the linked issue.

I don't completely understand the meaning of includeWhereClause in this context but I think false is the correct value for this call?

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

@Dargones Dargones changed the title fix: Dafny to Boogie printing fix: Don't name formals of Dafny to Boogie FunctionHandles Jun 16, 2022
@Dargones Dargones changed the title fix: Don't name formals of Dafny to Boogie FunctionHandles fix: Don't name formals of FunctionHandles Jun 16, 2022
@Dargones Dargones changed the title fix: Don't name formals of FunctionHandles fix: Fix naming of formals in Translator Jun 17, 2022
@robin-aws
Copy link
Member

Thanks @Dargones! This LGTM in general, although I also don't fully understand the includeWhereClause parameter so I'm not 100% sure false is correct.

In the meantime, can you add a new test case to expose the issue somehow? I'd like to get to the bottom of why this only shows up when you manually verify the Boogie code separately - it might point to the Dafny pipeline failing to pass an option to catch this error more strictly.

@Dargones
Copy link
Collaborator Author

Dargones commented Jun 20, 2022

Thank you, @robin-aws. I have added a test case and it succeeds when I run it with lit directly but fails here because, I think, it is executed via IntergrationTests.csproj. It might be possible to add BoogieDriver as a dependency to IntegrationTests.csproj but I am not completely sure, so I am wondering what the right way to do this would be. Is there a directory for tests that are executed directly with lit?

This test also adds additional overhead of having to build Boogie but I think it could be useful for more extensive testing of the Dafny -> Boogie file -> Verify with Boogie pipeline.

More about the bug: the reason the verification succeeds when running Dafny alone is because all parameters have names, one of these names happens to be an empty string. However, when this empty string name is printed to file along with other parameter banes, which are not empty, Boogie cannot parse it back. If, on the other hand, none of the parameters have names, then Boogie can successfully parse the function definition.

More specifically, the bug seems to be triggered by adding a reads clause for a function type parameter, hence the test case:

function Test(f: (int ~> bool)): (b:bool) reads f.reads { true }

As for the includeWhereClause parameter, I think false is the correct value, since I couldn't find where clauses on function parameters in any of the

@robin-aws
Copy link
Member

Great, thanks for the explanation. I fully agree being able to automatically test the Dafny -> Boogie file -> Verify with Boogie workflow is extremely useful, given many contributors will use that to debug issues with the translator (I know I have :).

Rather than building Boogie from source we could just install the corresponding release of the boogie dotnet tool from nuget in our CI. In fact the easiest solution is just to add it to our dotnet-tools.json.

As for the includeWhereClause parameter, I think false is the correct value, since I couldn't find where clauses on function parameters in any of the

I think you accidentally a few words :)

@Dargones
Copy link
Collaborator Author

I believe I have been able to fix the testing process (pending integration tests rerun, which was successful on my fork). @robin-aws - let me know if there is anything else I could do to merge this in!

atomb
atomb previously approved these changes Dec 19, 2022
Copy link
Member

@atomb atomb left a comment

Choose a reason for hiding this comment

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

I love the fix/test ratio on this one. ;)

@Dargones
Copy link
Collaborator Author

Thank you for approving, @atomb! I have synced the PR with master so it should be good to go

@robin-aws robin-aws enabled auto-merge (squash) February 1, 2023 17:44
@robin-aws robin-aws merged commit 889e051 into dafny-lang:master Feb 1, 2023
robin-aws added a commit to robin-aws/dafny that referenced this pull request Feb 2, 2023
keyboardDrummer pushed a commit that referenced this pull request Feb 2, 2023
This reverts commit 889e051.

The implementation of configuring Z3 for `%boogie` wasn't working in the
nightly build.

<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>
Dargones added a commit to Dargones/dafny that referenced this pull request Feb 16, 2023
atomb added a commit that referenced this pull request Feb 22, 2023
This is a new version of #2266 with changes that should make it pass all
tests, both on the PR stage and during the nightly build. The reason
#2266 failed during nightly build was that path to Z3 used to be
different for different operation systems and modes of testing. This PR
adds symbolic links that ensure there is a path to Z3 applicable to all
cases.

More specifically, right now Z3 resides at `dafny/Binaries/z3/bin/z3` if
testing on Ubuntu outside the nightly build (see
[here](https://github.com/dafny-lang/dafny/blob/0d78ab50330d64dd769b674cd0125a9ffc994b20/.github/workflows/integration-tests-reusable.yml#L114-L120)),
at `unzippedRelease/dafny/z3/bin/z3` if testing on Ubuntu/MacOS during
the nightly build (see
[here](https://github.com/dafny-lang/dafny/blob/0d78ab50330d64dd769b674cd0125a9ffc994b20/.github/workflows/integration-tests-reusable.yml#L111-L113))
and at `unzippedRelease/dafny/z3/bin/z3.exe` when testing on Windows
([here](https://github.com/dafny-lang/dafny/blob/0d78ab50330d64dd769b674cd0125a9ffc994b20/.github/workflows/integration-tests-reusable.yml#L107-L110)).
This PR modifies the [workflow
file](https://github.com/dafny-lang/dafny/blob/master/.github/workflows/integration-tests-reusable.yml)
to have symbolic links to ensure that `unzippedRelease\dafny\z3\bin\z3`
always points to Z3, whatever the operations system and testing
strategy.

Aside from the Z3 path this PR is identical to #2266 and fixes #2263.

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

Co-authored-by: Aaron Tomb <[email protected]>
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.

Dafny translates a file from the standard library to a syntacticly invalid Boogie code
3 participants