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

Bad encoding for this in tail recursive functions when compiling to Java #5532

Open
fabiomadge opened this issue Jun 5, 2024 · 1 comment
Labels
during 2: compilation of correct program Dafny rejects a valid program during compilation kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label lang: java Dafny's Java transpiler and its runtime priority: not yet Will reconsider working on this when we're looking for work

Comments

@fabiomadge
Copy link
Collaborator

Dafny version

master

Code to produce this issue

class C {
  var data: nat
  constructor() {}
  function Loop(xs: seq<()>): () reads this {
    if |xs| == 0
    then ()
    else
      var _ := forall c :: c in { this } ==> c.data == this.data;
      var _ := set n: nat {:trigger n * 1} | n < 100 && n == this.data;
      var _ := map n: nat {:trigger n * 1} | n < 100 :: this;
      Loop(xs[1..])
  }
}

method Main(){
  var c := new C();
  print c.Loop([(), ()]), "\n";
}

Command to run and resulting output

No response

What happened?

Java lambdas don't support the way we use them.

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

Mac

@fabiomadge fabiomadge added kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label lang: java Dafny's Java transpiler and its runtime during 2: compilation of correct program Dafny rejects a valid program during compilation labels Jun 5, 2024
@stefan-aws
Copy link
Collaborator

Can confirm that running above code with java as target throws an error (error: local variables referenced from a lambda expression must be final or effectively final).

@stefan-aws stefan-aws added priority: not yet Will reconsider working on this when we're looking for work and removed priority: unknown labels Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
during 2: compilation of correct program Dafny rejects a valid program during compilation kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label lang: java Dafny's Java transpiler and its runtime priority: not yet Will reconsider working on this when we're looking for work
Projects
None yet
Development

No branches or pull requests

2 participants