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

Regression: dafny run not working with include #4139

Closed
davidcok opened this issue Jun 6, 2023 · 4 comments · Fixed by #4212 · May be fixed by #4230
Closed

Regression: dafny run not working with include #4139

davidcok opened this issue Jun 6, 2023 · 4 comments · Fixed by #4212 · May be fixed by #4230
Assignees
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label release-blocker Must be resolved before the next release

Comments

@davidcok
Copy link
Collaborator

davidcok commented Jun 6, 2023

Dafny version

4.1.0

Code to produce this issue

test.dfy:
include "main.dfy"

method Main() {
  var undertest := new TestLogic''TopLevel();
  print "COMPLETED OK\n";
}

main.dfy:
class TestLogic''TopLevel {
  constructor () 
  {
  }
}

Command to run and resulting output

dafny run --no-verify test.dfy

test.dfy(4,19): Error: call to undeclared procedure: Call$$_module.TestLogic_k_kTopLevel.__ctor
1 name resolution errors detected in /var/folders/89/bc5ryf6x55l_pm4w3347kd200000gn/T/test__module.bpl

*** Encountered internal translation error - re-running Boogie to get better debug information

/var/folders/89/bc5ryf6x55l_pm4w3347kd200000gn/T/test__module.bpl(2882,4): Error: call to undeclared procedure: Call$$_module.TestLogic_k_kTopLevel.__ctor
1 name resolution errors detected in /var/folders/89/bc5ryf6x55l_pm4w3347kd200000gn/

What happened?

  1. It does not work as it should
  2. Why is there any reference to bpl files at all? No verification is called for.
  3. It works fine if the files are combined into one file, without using include.

4!!!) If one includes the option --verify-included-files, enven though one also has --no-verify, then it works.

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

Mac

@davidcok davidcok added the kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label label Jun 6, 2023
@davidcok davidcok changed the title dafny run not working with include Regression: dafny run not working with include Jun 22, 2023
@robin-aws robin-aws added the release-blocker Must be resolved before the next release label Jun 22, 2023
@robin-aws
Copy link
Member

Tagging as release blocker to be conservative, if indeed a regression.

@MikaelMayer
Copy link
Member

This issue was first introduced by the PR #4059 after bisecting. @keyboardDrummer before I dive into it, would you know what in your PR caused that trouble?

@keyboardDrummer
Copy link
Member

keyboardDrummer commented Jun 22, 2023

The translation code decides what to skip translation for based on whether it was included or not, and apparently it's skipping things too aggressively here causing the translated code from the including file to have a reference to something that wasn't translated. I guess the bug starts in Translator.InVerificationScope(Declaration d) or Translator.ShouldVerifyModule(..)

--no-verify apparently doesn't prevent translation from happening so that's not significant to this.

@MikaelMayer
Copy link
Member

Ok, after investigation, here is what I found so far.
Since #4059, translation happens in this order
image

Before #4059, translation happened in this order:
image

So before, it was translating the main module, and then adding "_ctor" as a referenced method.
Then it proceeded to translate the class and, because _ctor was referenced, it would adds it procedure.

After, it would translate the class first, and because _ctor is not referenced yet and out of scope, it would not add it to the translation. Then it proceeded to translate _default and adds a reference to the _ctor method, but it's too late.
I'll look into why that happens.

MikaelMayer added a commit that referenced this issue Jun 22, 2023
keyboardDrummer pushed a commit to keyboardDrummer/dafny that referenced this issue Jun 30, 2023
@keyboardDrummer keyboardDrummer self-assigned this Jul 11, 2023
MikaelMayer added a commit that referenced this issue Jul 12, 2023
…4212)

This PR fixes #4139
I'm not sure of the fix right now, need to see if it works on other
tests. I suspect it will fail and we might need another way to separate
the TopLevelDecls order for verification as well. But let's see.

<small>By submitting this pull request, I confirm that my contribution
is made under the terms of the [MIT
license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>

---------

Co-authored-by: Remy Willems <[email protected]>
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 release-blocker Must be resolved before the next release
Projects
None yet
4 participants