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

Avoid duplicate names when compiling arrow types #5328

Merged
merged 6 commits into from
Apr 18, 2024

Conversation

atomb
Copy link
Member

@atomb atomb commented Apr 16, 2024

Description

Dafny previously could generate duplicate variable names when translating arrow types. For example, when compiling this file to Java with the following command:

dafny build --target:java --unicode-char:false JSONParser.dfy

How has this been tested?

Manual testing of the above command, plus a new test: comp/DuplicateArrowNames.dfy.

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

@atomb atomb marked this pull request as ready for review April 16, 2024 21:46
Copy link
Member

@keyboardDrummer keyboardDrummer left a comment

Choose a reason for hiding this comment

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

Let's add a test before merging

@MikaelMayer
Copy link
Member

I would love to merge it asap because it contains a hot fix for a user, but at the same time I understand that without testing, the fix might not be as robust as we are used to. Since this PR does not claim to fix any issue, could this be just considered code refactoring? Down the road we could make use of the upcoming parsers combinators library as a safeguard test.
Otherwise, of course, if Aaron can find a smaller test to reproduce the error, I would love it.

@fabiomadge
Copy link
Collaborator

Here's one that fails for Java:

method Main() {
  var f: nat -> nat -> bool;
  print f, "\n";
}

@atomb
Copy link
Member Author

atomb commented Apr 17, 2024

Here's one that fails for Java:

method Main() {
  var f: nat -> nat -> bool;
  print f, "\n";
}

Thanks! I'll add that one.

@atomb atomb enabled auto-merge (squash) April 17, 2024 16:50
Copy link
Collaborator

@fabiomadge fabiomadge left a comment

Choose a reason for hiding this comment

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

Sorry for the late intervention.

// and Python.
method Main() {
var f: nat -> nat -> bool;
print f, "\n";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
print f, "\n";
print f(0,1), "\n";

This way we get more uniform output.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, yeah, I like that. :)

@atomb atomb merged commit 0ca6ae9 into dafny-lang:master Apr 18, 2024
20 checks passed
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.

None yet

4 participants