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]: solc_parsing for var[x][] dynamic arrays fails when inside top level struct #1327

Closed
plotchy opened this issue Aug 5, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@plotchy
Copy link
Contributor

plotchy commented Aug 5, 2022

Describe the issue:

Testing parser on various types and noticed this particular type fails to be parsed.

Type is used in solidity docs as bool[2][] pairsOfFlags;
https://docs.soliditylang.org/en/latest/types.html?highlight=array#allocating-memory-arrays

Code example to reproduce the issue:

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

struct my_struct {
    uint[][] a; // works fine
    uint[][3] b; // works fine
    uint[3][] c; // fails
    uint[3][3] d; // fails
    uint[2**20] e; // works fine
}
contract BaseContract{
    struct my_struct_2 {
        uint[][] f; // works fine
        uint[][3] g; // works fine
        uint[3][] h; // works fine
        uint[3][3] i; // works fine
        uint[2**20] j; // works fine
    }
    
    uint[3][] k; // works fine
}

Version:

0.8.3

Relevant log output:

Error in a.sol Traceback (most recent call last): File "/home/plotchy/code/packages/slither/slither/main.py", line 755, in main_impl ) = process_all(filename, args, detector_classes, printer_classes) File "/home/plotchy/code/packages/slither/slither/main.py", line 87, in process_all ) = process_single(compilation, args, detector_classes, printer_classes) File "/home/plotchy/code/packages/slither/slither/main.py", line 70, in process_single slither = Slither(target, ast_format=ast, **vars(args)) File "/home/plotchy/code/packages/slither/slither/slither.py", line 118, in init parser.parse_contracts() File "/home/plotchy/code/packages/slither/slither/solc_parsing/slither_compilation_unit_solc.py", line 485, in parse_contracts self._analyze_second_part(contracts_to_be_analyzed, libraries) File "/home/plotchy/code/packages/slither/slither/solc_parsing/slither_compilation_unit_solc.py", line 553, in _analyze_second_part self._analyze_top_level_structures() File "/home/plotchy/code/packages/slither/slither/solc_parsing/slither_compilation_unit_solc.py", line 631, in _analyze_top_level_structures struct.analyze() File "/home/plotchy/code/packages/slither/slither/solc_parsing/declarations/structure_top_level.py", line 57, in analyze elem_parser.analyze(self) File "/home/plotchy/code/packages/slither/slither/solc_parsing/variables/variable_declaration.py", line 210, in analyze self._variable.type = parse_type(self._elem_to_parse, caller_context) File "/home/plotchy/code/packages/slither/slither/solc_parsing/solidity_types/type_parsing.py", line 401, in parse_type array_type = parse_type(t["baseType"], next_context) File "/home/plotchy/code/packages/slither/slither/solc_parsing/solidity_types/type_parsing.py", line 400, in parse_type length = parse_expression(t["length"], caller_context) File "/home/plotchy/code/packages/slither/slither/solc_parsing/expressions/expression_parsing.py", line 255, in parse_expression assert isinstance(caller_context, CallerContextExpression) AssertionError
@plotchy plotchy added the bug-candidate Bugs reports that are not yet confirmed label Aug 5, 2022
@0xalpharush 0xalpharush added bug Something isn't working and removed bug-candidate Bugs reports that are not yet confirmed labels Aug 5, 2022
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