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

Formatter bug #3944

Closed
MikaelMayer opened this issue May 3, 2023 · 0 comments · Fixed by #3946
Closed

Formatter bug #3944

MikaelMayer opened this issue May 3, 2023 · 0 comments · Fixed by #3946
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: formatter Code formatter for Dafny source code

Comments

@MikaelMayer
Copy link
Member

Dafny version

4.0.0

Code to produce this issue

function Example(
  newNames : map<string, string> := map[],
  a: int
) : bool
{
  true
}

Command to run and resulting output

dafny format

function Example(
  newNames : map<string, string> := map[],
                                        a: int
) : bool
{
  true
}

What happened?

The second argument shouldn't be badly formatted

What type of operating system are you experiencing the problem on?

Windows

@MikaelMayer MikaelMayer added kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: formatter Code formatter for Dafny source code labels May 3, 2023
robin-aws pushed a commit that referenced this issue May 3, 2023
This PR fixes #3944. I first recreated the issue with a test, and then
fixed it.
It turned out, formals had a field "DefaultValue" which was never
considered as a child, so its tokens were considered to be part of the
declaration, which messed up indentation.
The fix was to ensure Formals now take the default value also in their
range, and also in their children.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: formatter Code formatter for Dafny source code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant