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]: slither-flat can't flatten contracts containing structs with nested-arrays #1702

Closed
asmitadhungana opened this issue Mar 1, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@asmitadhungana
Copy link

Describe the issue:

The slither-flattener can flatten a library/contract that contain structs with single arrays as their elements but can't flatten contracts that contain structs with double arrays as elements.

Code example to reproduce the issue:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

struct DoubleArray {
  uint256[2][2] doubleArray;
}

library Lib_Throws_Error {
    function add(DoubleArray memory ss) internal view returns (bool) {
        return true;
    }
}

Command:

slither-flat contracts/crytic/e2e-fuzz/Lib.sol --strategy OneFile --pragma-solidity 0.8.7

Version:

0.9.1

Relevant log output:

Traceback (most recent call last):
  File "/opt/homebrew/bin/slither-flat", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.10/site-packages/slither/tools/flattening/__main__.py", line 112, in main
    slither = Slither(args.filename, **vars(args))
  File "/opt/homebrew/lib/python3.10/site-packages/slither/slither.py", line 125, in __init__
    parser.parse_contracts()
  File "/opt/homebrew/lib/python3.10/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 489, in parse_contracts
    self._analyze_second_part(contracts_to_be_analyzed, libraries)
  File "/opt/homebrew/lib/python3.10/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 557, in _analyze_second_part
    self._analyze_top_level_structures()
  File "/opt/homebrew/lib/python3.10/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 635, in _analyze_top_level_structures
    struct.analyze()
  File "/opt/homebrew/lib/python3.10/site-packages/slither/solc_parsing/declarations/structure_top_level.py", line 57, in analyze
    elem_parser.analyze(self)
  File "/opt/homebrew/lib/python3.10/site-packages/slither/solc_parsing/variables/variable_declaration.py", line 210, in analyze
    self._variable.type = parse_type(self._elem_to_parse, caller_context)
  File "/opt/homebrew/lib/python3.10/site-packages/slither/solc_parsing/solidity_types/type_parsing.py", line 419, in parse_type
    array_type = parse_type(t["baseType"], next_context)
  File "/opt/homebrew/lib/python3.10/site-packages/slither/solc_parsing/solidity_types/type_parsing.py", line 418, in parse_type
    length = parse_expression(t["length"], caller_context)
  File "/opt/homebrew/lib/python3.10/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 258, in parse_expression
    assert isinstance(caller_context, CallerContextExpression)
AssertionError
@asmitadhungana asmitadhungana added the bug-candidate Bugs reports that are not yet confirmed label Mar 1, 2023
@asmitadhungana asmitadhungana changed the title [Bug-Candidate]: slither-flat can't flatten contracts containing structs with double-arrays [Bug-Candidate]: slither-flat can't flatten contracts containing structs with nested-arrays Mar 1, 2023
@0xalpharush 0xalpharush added bug Something isn't working and removed bug-candidate Bugs reports that are not yet confirmed labels Mar 6, 2023
@0xalpharush 0xalpharush changed the title [Bug-Candidate]: slither-flat can't flatten contracts containing structs with nested-arrays [Bug]: slither-flat can't flatten contracts containing structs with nested-arrays Mar 6, 2023
@asmitadhungana
Copy link
Author

Hi, what's the status on this bug-fix process?
Also, would this bug prevent echidna from testing a similar contract containing multidimensional arrays?
For my testing process, even on similar contracts flattened using other flattening tools, running echidna-test won't get past the static-analysis part, due to Slither issues.

@smonicas
Copy link
Contributor

This issue was fixed in slither 0.9.2 with #1545. Update slither and it should work.

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

3 participants