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]: No tuple variable assigned when call destination is compound expression #1923

Open
kevinclancy opened this issue May 17, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@kevinclancy
Copy link
Contributor

Describe the issue:

When I invoke a multi-return method on a cast expression, the generated IR does not contain a HighLevelCall operation to initialize a tuple variable.

I think this only happens if the method has at least one parameter.

Code example to reproduce the issue:

pragma solidity ^0.8.19;

interface ISomeInterface {
    function value(uint z) external returns (uint, uint);
}

contract Test {

    function test(address a) external {
        (uint256 w, uint256 x) = ISomeInterface(a).value(3);
    }
}

Version:

0.9.3

Relevant log output:

INFO:Printers:Contract ISomeInterface
        Function ISomeInterface.value(uint256) (*)
Contract Test
        Function Test.test(address) (*)
                Expression: (w,x) = ISomeInterface(a).value(3)
                IRs:
                        TMP_0 = CONVERT a to ISomeInterface
                        w(uint256)= UNPACK TUPLE_0 index: 0 
                        x(uint256)= UNPACK TUPLE_0 index: 1 
                Expression: ()
                IRs:
                        RETURN
@0xalpharush
Copy link
Contributor

I think it only happens when the method is named "value" because it's incorrectly is treated as a function call option ({value:..}) by is_value here

if is_value(ins) and isinstance(prev_ins, Argument):

@kevinclancy
Copy link
Contributor Author

kevinclancy commented May 17, 2023

It seems this is an inherent problem with solc versions prior to 0.7.0.

For solc versions 0.7.0 and higher, slither could refrain from performing the filtering that is causing this issue.

For versions prior to 0.7.0, it's probably possible to distinguish call options from functions called value and gas from inside solc_parsing. Another approach would be to halt and produce an error message if it encounters declarations for functions named "value" or "gas".

@0xalpharush 0xalpharush added bug Something isn't working and removed bug-candidate Bugs reports that are not yet confirmed labels May 19, 2023
@0xalpharush 0xalpharush changed the title [Bug-Candidate]: No tuple variable assigned when call destination is compound expression [Bug]: No tuple variable assigned when call destination is compound expression May 19, 2023
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

2 participants