microsoft / verisol

A formal verifier and analysis tool for Solidity Smart Contracts
Other
245 stars 46 forks source link

Multiple Return Value Assertion Violation #232

Open stephensj2 opened 4 years ago

stephensj2 commented 4 years ago

In Solidity, when a function can return multiple values it is sometimes desirable to declare new variables to store those values. It is possible to do so by declaring the variables inside a tuple like so: (uint i, uint j) = fn();

However, such a declaration violates an assertion inside of VeriSol resulting in the following output:

Assertion Failed at SolidityAST.VariableDeclarationStatement.Accept(IASTVisitor visitor) in SolidityAST.cs:line 1274

This error message makes it difficult to understand why the translation failed. It would therefore be helpful if this behavior was either explicitly disallowed (similar to low-level calls), or supported by VeriSol. If the behavior were to be disallowed, the user could easily fix the problem by transforming the above code into: uint i; uint j; (i, j) = fn();

A simple test case that violates this assertion is provided below.

bug1.txt