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

{:compile false} has no effect on modules #4782

Closed
robin-aws opened this issue Nov 15, 2023 · 0 comments · Fixed by #4790
Closed

{:compile false} has no effect on modules #4782

robin-aws opened this issue Nov 15, 2023 · 0 comments · Fixed by #4790
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label

Comments

@robin-aws
Copy link
Member

Dafny version

4.3.0 (but has been true for a long time AFAICT)

Code to produce this issue

module {:compile false} PretendI'mNotHere {

  method Main() {
    print "BOO\n";
  }
}

Command to run and resulting output

% dafny run Scratch.dfy

Dafny program verifier finished with 0 verified, 0 errors
BOO

What happened?

According to the reference manual {:compile false} should apply to "any top-level declaration". There are even test cases in the integration suite that seem to believe the attribute should work on modules, but AFAICT no test actually verifies no code is outputted.

This is especially an issue for externs in Go (and likely Python as well), since examples like comp/Extern.dfy only work because passing the extra Extern.go file on the CLI causes it to overwrite the incorrectly Dafny-generated Extern.go file.

Although I'm a bit worried about just fixing this, since there may be code out there using {:compile false} on modules anyway, it seems like no longer emitting code as directed is extremely likely to break loudly.

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

Mac

@robin-aws robin-aws added the kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label label Nov 15, 2023
robin-aws added a commit that referenced this issue Nov 17, 2023
…4790)

### Description
Adds build support for standard libraries with different Dafny and
target language source code per backend, and imports the `FileIO`
library.

The build support mainly adds a set of
`DafnyStandardLibraries-<target>.doo` files, and a common
`DafnyStandardLibraries-notarget.doo` file with only the abstract
interface. The pattern looks a lot like [replaceable
modules](#4681), but is less
efficient for now because it re-verifies common code rather than relying
on refinement.

Please pay particular attention to the documentation updates as this
does slightly affect the user experience with standard libraries!

Major changes to `FileIO` on the way in:
* Refactored to separate the externs into its own module, so it could be
defined differently per backend without duplicating the common wrapper
logic.
* Added support for Go and Javascript.
* Removed the comments about additional source files in the `README.md`
since it's all automatic now (yay!)

Other supporting changes:
* Fixes #4782, as otherwise Go was messy to implement and Python nearly
impossible.
* Added utilities in the Go runtime for converting between
`_dafny.Sequence` and `[]byte`.
* Added an automatic build of Dafny itself at the end of `make
update-binary`, since failing to do that and therefore not picking up
the new versions of the `.doo` files was a common gotcha.
* Switched CI job that tests the standard libraries from Ubuntu to Mac
OS: diffing checked in `.doo` files against fresh builds of them was
failing for what looks like whitespace/newline variation. It makes more
sense to stick to Mac OS for verification of production Dafny code
anyway, however, since most contributors are developing on macs and
[verification is not guaranteed to be consistent across
platforms](#1807).

### How has this been tested?
`StandardLibraries_TargetSpecific.dfy` for the general support,
`FileIOExamples.dfy` for `FileIO` itself (mainly the same as the
original library, adapted as Dafny tests instead of lit tests)

---------

Co-authored-by: Alex Chew <alex-chew@users.noreply.github.com>
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant