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 pass #2715

Open
wants to merge 3 commits into
base: dind
Choose a base branch
from
Open

Formatter pass #2715

wants to merge 3 commits into from

Conversation

MikaelMayer
Copy link
Member

This PR used the formatter being developed in #2399 to format all the dafny files

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

@@ -1,350 +1,350 @@
include "CSharpDafnyASTModel.dfy"
include "CSharpDafnyASTModel.dfy"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is the include indented?

Copy link
Member Author

Choose a reason for hiding this comment

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

Congratulations, you found a bug 🥈

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in the new version

Source/DafnyCompilers/AST.dfy Show resolved Hide resolved
Source/DafnyCompilers/AST.dfy Outdated Show resolved Hide resolved
Copy link
Member

@mschlaipfer mschlaipfer left a comment

Choose a reason for hiding this comment

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

Nice progress!

| MultisetCard
| MapCard
| MemberSelect(name: string)
// Ghost operators
Copy link
Member

Choose a reason for hiding this comment

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

wrong indent?

Copy link
Member Author

Choose a reason for hiding this comment

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

Very good finding, but that's expected.

  1. We plan to have docstring to be comments like this one right after a constructor, so it's correctly aligned.
  2. The comments just below // | are aligned with the | above because the Dafny formatter recognizes that this is a commented case of a constructor.

&& f.requires(e)
&& Deep.AllChildren_Expr(e', post)
==> f.requires(e')
&& Exprs.ConstructorsMatch(e, e')
Copy link
Member

Choose a reason for hiding this comment

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

seems better before?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll add this to my final survey list, as I like the one on the right.

{
forall e: Expr | Deep.AllChildren_Expr(e, post) && f.requires(e) ::
Deep.All_Expr(f(e), post)
Deep.All_Expr(f(e), post)
Copy link
Member

Choose a reason for hiding this comment

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

what happens here?

Copy link
Member Author

Choose a reason for hiding this comment

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

You found a bug, congrats ! 🥉

eq_value: (WV,WV) -> bool, ctx: Context, ctx': Context
)
eq_value: (WV,WV) -> bool, ctx: Context, ctx': Context
)
Copy link
Member

Choose a reason for hiding this comment

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

is this better?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll add this to my final survey as I like the one on the right better. That way, arguments don't have the same indentation as the body of the predicate/function, which makes it easy to determine the limit between the two.

@@ -1,4 +1,4 @@
include "Library.dfy"
include "Library.dfy"
Copy link
Member

Choose a reason for hiding this comment

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

wrong indent?

Copy link
Member Author

Choose a reason for hiding this comment

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

Bug for which I pushed a fix on Friday, but I did not update this. Now it's done. Thanks

case FunctionCall() =>
InterpFunctionCall(e, env, argvs[0], argvs[1..])
})
case UnaryOp(op: UnaryOp) =>
Copy link
Member

Choose a reason for hiding this comment

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

there's a code highlighting bug

Copy link
Member Author

Choose a reason for hiding this comment

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

With the newest version, the code diff is no longer a problem, can you have a look and let me know if this is ok?
I still think the indentation of the match case should be more aligned.

Success(V.BitVector(v0.width, Math.IntPow(2, v0.width) - 1 - v0.value))
case BoolNot => :- Need(v0.Bool?, Invalid(expr));
Success(V.Bool(!v0.b))
case SeqLength => :- Need(v0.Seq?, Invalid(expr));
Copy link
Member

Choose a reason for hiding this comment

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

could we have a linebreak after =>? Why is Success aligned with the RHS of :-?

Copy link
Member Author

Choose a reason for hiding this comment

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

The scope of the formatter does not include adding newlines.
Success is now aligned with :- and nots its RHS

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

3 participants