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

implicit, named return does not have RETURN node #1450

Closed
0xalpharush opened this issue Nov 3, 2022 · 2 comments
Closed

implicit, named return does not have RETURN node #1450

0xalpharush opened this issue Nov 3, 2022 · 2 comments
Labels
enhancement New feature or request ir

Comments

@0xalpharush
Copy link
Contributor

function test() external view returns (uint named) {
     named = 1;
     // name in return parameter list indicates implicit return
}

The AST does not contain a ReturnStatement so we never create a RETURN node. We can enhance slithIR with this implicit return and change the node's type.

@webthethird
Copy link
Contributor

We can enhance slithIR with this implicit return and change the node's type.

You mean change the type of the node containing the AssignmentOperation from EXPRESSION to RETURN, right?
Would this be done after parsing the function's CFG? And is it necessary that the node with the AssignmentOperation have no children?

0xalpharush added a commit that referenced this issue Mar 1, 2024
Fix/model named returns:

Resolves issues #1450 and #1719, and includes the previously failing test from #1818, which now passes.

Creates an artificial return node iff a function has a named return variable declared in its signature. Finds all leaf nodes in the CFG which are not return nodes, and links them to the artificial return node. The return node is given an Identifier expression with a referencedDeclaration pointing to the variable declaration in the signature.

Once this return node is in place and correctly linked, subsequent analyses resolve the data dependency issue for named variables without any further changes, i.e., to Slither's IR generation. The goal being to implement the simplest solution to that problem.
@0xalpharush
Copy link
Contributor Author

closed by #2326

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ir
Projects
None yet
Development

No branches or pull requests

2 participants