Skip to content

[Bug]: Slither does not distinguish between types and type expressions #2089

Open
@kevinclancy

Description

@kevinclancy

Describe the issue:

Slither doesn't distinguish between type expressions, of which uint[NUM_PHASES] is a member, and types, of which uint[NUM_PHASES] is not a member but uint[3] is. This causes it to miss applications of using/for.

In the example source, Slither does not convert the type expression uint[NUM_PHASES] to the type uint[3], and so IR generation is unable to recognize z.proj0 as a library call.

Code example to reproduce the issue:

library Lib {
    function proj0(uint[3] memory a) external returns(uint) {
        return a[0];
    }
}

contract Test {
    uint constant NUM_PHASES = 3;

    using Lib for uint[3];

    function test(uint[NUM_PHASES] memory z) external {
        z.proj0();
    }
}

Version:

0.9.6

Relevant log output:

INFO:Printers:Contract Lib
        Function Lib.proj0(uint256[3]) (*)
                Expression: a[0]
                IRs:
                        REF_0(uint256) -> a[0]
                        RETURN REF_0
Contract Test
        Function Test.test(uint256[3]) (*)
                Expression: z.proj0()
                IRs:
                        TMP_0(None) = HIGH_LEVEL_CALL, dest:z(uint256[3]), function:proj0, arguments:[]  
        Function Test.slitherConstructorConstantVariables() (*)
                Expression: NUM_PHASES = 3
                IRs:
                        NUM_PHASES(uint256) := 3(uint256)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingir

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions