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

Java Build Name Clash #4336

Open
DavePearce opened this issue Jul 25, 2023 · 0 comments
Open

Java Build Name Clash #4336

DavePearce opened this issue Jul 25, 2023 · 0 comments
Assignees
Labels
crash Dafny crashes on this input, or generates malformed code that can not be executed during 2: compilation of correct program Dafny rejects a valid program during compilation invalid translated code The compiler generates invalid code, making the the target language infrastructure crash kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label lang: java Dafny's Java transpiler and its runtime part: code-generation Support for transpiling Dafny to another language. If relevant, add a `lang:` tag priority: next Will consider working on this after in progress work is done

Comments

@DavePearce
Copy link

DavePearce commented Jul 25, 2023

Dafny version

4.2.0

Code to produce this issue

module Stack {
  type StackContent = s:seq<nat> | |s| < 65536

  datatype Stack = Stack(contents: StackContent)

  function Create() : Stack {
    Stack([])
  }
}

module Main {
  import Stack

  datatype VM = OK(pc: nat, stack: Stack.Stack) {
    function next() : VM {
      var st ≔ Stack.Create();
      OK(0,st)
    }
  }
}

Command to run and resulting output

dafny build --target java src/main.dfy
Dafny program verifier finished with 3 verified, 0 errors
/home/djp/projects/DafnyBug/src/main-java/Main/VM.java:67: error: cannot find symbol
    dafny.DafnySequence<? extends java.math.BigInteger> _0_st = Stack.__default.Create();
                                                                     ^
  symbol:   variable __default
  location: class Stack
1 error
Error while compiling Java files. Process exited with exit code 1

What happened?

The problem is that, at the top of the generated Java file we have:

import Stack.*;

This results in the call Stack.__default.Create() applying not to the package, but to the generated class Stack.

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

Linux

@DavePearce DavePearce added the kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label label Jul 25, 2023
@alex-chew alex-chew added part: code-generation Support for transpiling Dafny to another language. If relevant, add a `lang:` tag lang: java Dafny's Java transpiler and its runtime invalid translated code The compiler generates invalid code, making the the target language infrastructure crash labels Jul 26, 2023
@keyboardDrummer keyboardDrummer added the crash Dafny crashes on this input, or generates malformed code that can not be executed label Feb 2, 2024
@atomb atomb self-assigned this Feb 6, 2024
@keyboardDrummer keyboardDrummer added the during 2: compilation of correct program Dafny rejects a valid program during compilation label Feb 7, 2024
@atomb atomb removed their assignment Mar 5, 2024
@keyboardDrummer keyboardDrummer added the priority: next Will consider working on this after in progress work is done label Apr 25, 2024
@stefan-aws stefan-aws self-assigned this May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Dafny crashes on this input, or generates malformed code that can not be executed during 2: compilation of correct program Dafny rejects a valid program during compilation invalid translated code The compiler generates invalid code, making the the target language infrastructure crash kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label lang: java Dafny's Java transpiler and its runtime part: code-generation Support for transpiling Dafny to another language. If relevant, add a `lang:` tag priority: next Will consider working on this after in progress work is done
Projects
None yet
Development

No branches or pull requests

5 participants