-
Notifications
You must be signed in to change notification settings - Fork 253
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
Disable ShowSnippets during Test Generation #4216
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest you add a comment in the ref-man as well that --show-snippets is always disabled for these two commands.
Thank you for pointing out to the reference manual, @davidcok! I have added a note about |
Can't we change that? |
In principle, yes, and I am working on an overhaul of inlining that will move many AST traversals from Boogie to Dafny and move the code closer to addressing this issue. However, I don't think I know of a way to immediately make sure all tokens can be cast. One major obstacle is that I need to copy Boogie ASTs and the only way of doing this is by printing them to file and then parsing, which loses all connection to Dafny tokens. In the near future, I think, the only way of making sure test generation does not break is by disabling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mostly looks great. The one suggestion I have is to also fix ShowSnippets for the case where there is no Dafny source location information available. I'm thinking that you could replace this code:
dafny/Source/DafnyCore/DafnyConsolePrinter.cs
Lines 104 to 106 in d72dc7a
if (Options.Get(ShowSnippets)) { | |
WriteSourceCodeSnippet(tok, tw); | |
} |
with something like
if (Options.Get(ShowSnippets)) {
if(tok is IToken dafnyTok) {
WriteSourceCodeSnippet(dafnyTok, tw);
} else {
ErrorWriteLine(tw, "No Dafny location information, so snippet can't be generated.");
}
}
And then make WriteSourceCodeSnippet
take a Dafny token instead of a Boogie token.
Thank you, @atomb! This makes sense, I have made the change. |
One tiny additional thing: it seems like the format check wants some white space changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
The `--show-snippets` breaks test generation because it relies on casting of `Boogie.IToken` to `Dafny.IToken` [here](https://github.com/dafny-lang/dafny/blob/d72dc7a85ae5d662dda78f927463d1e56b4a0696/Source/DafnyCore/DafnyConsolePrinter.cs#L54) and test generation makes changes to the Boogie AST that may introduce new tokens that cannot be cast. This PR disables the option, recently enabled by default, during test generation. An alternative would be to surround the cast with try-catch, but it seems that outside test generation purposes it is probably safe to assume that the cast succeeds. @atomb, @robin-aws would it be possible to merge this before the next release to make sure test generation stays stable? By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license. --------- Co-authored-by: Aleksandr Fedchin <[email protected]>
The
--show-snippets
breaks test generation because it relies on casting ofBoogie.IToken
toDafny.IToken
here and test generation makes changes to the Boogie AST that may introduce new tokens that cannot be cast. This PR disables the option, recently enabled by default, during test generation. An alternative would be to surround the cast with try-catch, but it seems that outside test generation purposes it is probably safe to assume that the cast succeeds. @atomb, @robin-aws would it be possible to merge this before the next release to make sure test generation stays stable?By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.