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

Fix recursion #5

Open
igorline opened this issue Aug 29, 2023 · 1 comment
Open

Fix recursion #5

igorline opened this issue Aug 29, 2023 · 1 comment

Comments

@igorline
Copy link
Collaborator

igorline commented Aug 29, 2023

contract Fib {
    function fib(uint256 x) public pure returns (uint256) {
        if (x <= 1) return x;
        unchecked {
            return fib(x - 1) + fib(x - 2);
        }
    }
}
@plotchy
Copy link
Owner

plotchy commented Sep 1, 2023

idk if generally there is a good solution here. for this example I'm thinking you can read the stack size delta upon entry into the node, if it is positive then clone the current stack values within that size delta temporarily, and upon node exit compare the cloned stack values to the ones currently there. If they match, don't let the traverser continue.

but there are edge cases galore in doing things like this. ie:

graph TD;
    A[A: <br/> jumpdest <br/> push 1] --> B[B: <br/> jumpdest <br/> push 1];
    B --> C[C: <br/> push A <br/> jump];
    C --> A;
Loading

would break at B exit when it shouldnt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants