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

Incorrect super c3 linearalization #155

Closed
montyly opened this issue Jan 29, 2019 · 2 comments
Closed

Incorrect super c3 linearalization #155

montyly opened this issue Jan 29, 2019 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@montyly
Copy link
Member

montyly commented Jan 29, 2019

contract A {
    function getValue() public pure returns (uint) {
        return 0;
    }
}

contract B is A {
    function getValue() public pure returns (uint) {
        return 0;
    }
}

contract C is A {
    function getValue() public pure returns (uint) {
        return super.getValue() ;
    }
}

contract E is B, C {
}

In this example, slither will fail to understand that in the context of E, return super.getValue() ; is return B.getValue() ; (and in the context of C only, it is return A.getValue() ;

One solution is to create an instance of getValue in E, but that might break some existing code assumptions.
Another solution is to not translate super during the parsing, and to compute it only when needed.

@montyly montyly added the bug Something isn't working label Jan 29, 2019
@montyly montyly self-assigned this Jan 29, 2019
@montyly
Copy link
Member Author

montyly commented Apr 1, 2019

Another instance:

contract A{
    
    function f1() public{
        f2();
    }
    
    function f2() public{
    }
}

contract B is A{
    function f2() public{
        super.f2();
    }
}

f1() will incorrectly fix its internal call to A.f2, while it will be B.f2 in the B context. More I think about it, more I think we should delay the destination resolution of internal functions, and have a context-dependent resolver for it.

This can lead to incorrect results and must be fixed prior 0.7.0

@montyly
Copy link
Member Author

montyly commented May 21, 2019

Fixed in dev with #213

@montyly montyly closed this as completed May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant