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

[Bug-Candidate]: Missing IRs after usage of aliased-imported-library-type array. #1634

Closed
gfeng-certik opened this issue Jan 30, 2023 · 2 comments
Labels
bug-candidate Bugs reports that are not yet confirmed

Comments

@gfeng-certik
Copy link

Describe the issue:

SlithIR is not properly generated after a usage of an aliased-imported-library-type array. A more specific example can be found in the reproducer, but in short, having an import like import {DataTypes as dt} from "./DataTypes.sol"; and then declaring a variable like dt.Type[] memory v = ... causes slither to fail silently with log message Missing function Type not found dt.Type. This then causes the IRs for the current function and every function defined after it in the same contract to not be generated.

Code example to reproduce the issue:

In DataTypes.sol:

pragma solidity ^0.8.0;

library DataTypes {
    struct BoolPair {
        bool b1;
        bool b2;
    }
}

In Test.sol:

pragma solidity ^0.8.0;

import {DataTypes as dt} from "./DataTypes.sol";

contract Test {
    function functionWithIRs(bool x, bool y) public returns (bool) {
        bool b1 = x && y;
        bool b2 = x || y;
        return b1 && b2;
    }

    function hasBoolPair() public returns (bool) {
        bool b = true;
        dt.BoolPair memory bp = dt.BoolPair(true, false);
        return b;
    }

    function hasBoolPairArray() public returns (bool) {
        bool b = true;
        dt.BoolPair[] memory bpArr = new dt.BoolPair[](0);
        return b;
    }

    function sameAsFirstFunction(bool x, bool y) public returns (bool) {
        bool b1 = x && y;
        bool b2 = x || y;
        return b1 && b2;
    }

}

Version:

0.9.2

Relevant log output:

From using the slithir printer on the reproducer:

Contract DataTypes

Missing function Type not found dt.BoolPair
Missing function Type not found dt.BoolPair
Contract DataTypes
Contract Test
	Function Test.functionWithIRs(bool,bool) (*)
		Expression: b1 = x && y
		IRs:
			TMP_0(bool) = x && y
			b1(bool) := TMP_0(bool)
		Expression: b2 = x || y
		IRs:
			TMP_1(bool) = x || y
			b2(bool) := TMP_1(bool)
		Expression: b1 && b2
		IRs:
			TMP_2(bool) = b1 && b2
			RETURN TMP_2
	Function Test.hasBoolPair() (*)
		Expression: b = true
		IRs:
			b(bool) := True(bool)
		Expression: bp = DataTypes.BoolPair(true,false)
		IRs:
			TMP_3 = new BoolPair(True,False)
			bp(DataTypes.BoolPair) := TMP_3(DataTypes.BoolPair)
		Expression: b
		IRs:
			RETURN b
	Function Test.hasBoolPairArray() (*)
	Function Test.sameAsFirstFunction(bool,bool) (*)
@gfeng-certik gfeng-certik added the bug-candidate Bugs reports that are not yet confirmed label Jan 30, 2023
@0xalpharush
Copy link
Contributor

Thanks for opening this issue and including an example. We are tracking in #1452

@0xalpharush
Copy link
Contributor

I think this was fixed by #2166

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-candidate Bugs reports that are not yet confirmed
Projects
None yet
Development

No branches or pull requests

2 participants