Skip to content

Dafny generates double returns  #4520

Open
@TheGrandmother

Description

@TheGrandmother

Dafny version

4.2.0

Code to produce this issue

method five() returns (r:int) {
  return 5;
}

Command to run and resulting output

dafny build -t:js test.dfy
Generates:

    static five() {
      let r = _dafny.ZERO;
      r = new BigNumber(5);
      return r;
      return r;
    }

dafny build -t:go test.dfy
Generates:

func (_static *CompanionStruct_Default___) Five() _dafny.Int {
  var r _dafny.Int = _dafny.Zero
  _ = r
  r = _dafny.IntOfInt64(5)
  return r
  return r
}

dafny build -t:py test.dfy
Generates:

class default__:
    def  __init__(self):
        pass

    @staticmethod
    def five():
        r: int = int(0)
        r = 5
        return r
        return r

What happened?

Even though producing double returns isn't necessarily wrong, it is a bit ugly/silly and can cause warnings/errors from linters and other QA tools.

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

WSL

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: performancePerformance issueskind: enhancementEnhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafnylang: golangDafny's transpiler to Go and its runtimelang: javaDafny's Java transpiler and its runtimelang: pythonDafny's Python transpiler and its runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions