Skip to content

Bad Rust code generated when local variable shares name with return variable. #6261

@ajewellamz

Description

@ajewellamz

Dafny version

4.10 and also HEAD of master

Code to produce this issue

https://github.com/aws/aws-database-encryption-sdk-dynamodb/

Command to run and resulting output

clone https://github.com/aws/aws-database-encryption-sdk-dynamodb/
cd DynamoDbEncryption
make polymorph_rust transpile_rust test_rust
note that test_rust successfully compiles

Edit the file dafny/DynamoDbEncryption/src/FilterExpr.dfy
In the definition of apply_function on line 1267 (or so) change
returns (result : Result<StackValue, Error>)
to
returns (ret : Result<StackValue, Error>)

make transpile_rust test_rust
note that test_rust does not compile, even though it should, and in fact does in all the other languages.

It seems that code on 1274 that starts
var ret :- 
confuses Dafny, in that the variable has the same name as the return variable

What happened?

Generated rust code does not compile.
I expected it to compile, or at a minimum Dafny should have complained at transpilation time.

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

Mac

Metadata

Metadata

Assignees

No one assigned

    Labels

    during 2: compilation of correct programDafny rejects a valid program during compilationkind: bugCrashes, unsoundness, incorrect output, etc. If possible, add a `part:` labellang: rustDafny's transpiler to Rust and its runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions