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 cannot parse event arguments from global scope #2359

Closed
Tiko7454 opened this issue Mar 11, 2024 · 0 comments
Closed

[Bug]: Slither cannot parse event arguments from global scope #2359

Tiko7454 opened this issue Mar 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Tiko7454
Copy link
Contributor

Tiko7454 commented Mar 11, 2024

Describe the issue:

Events don't work with constants declared in the global scope. Also, the bug was not present on version 0.10.0

Code example to reproduce the issue:

uint constant A = 3;

contract C {
  event ev(uint[A]);
}

Version:

0.10.1

Relevant log output:

'solc --version' running
'solc Treasury.sol --combined-json abi,ast,bin,bin-runtime,srcmap,srcmap-runtime,userdoc,devdoc,hashes,compact-format --allow-paths .,/home/tigran' running
Compilation warnings/errors on Treasury.sol:
Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> Treasury.sol

Warning: Source file does not specify required compiler version! Consider adding "pragma solidity ^0.8.7;"
--> Treasury.sol


Traceback (most recent call last):
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/__main__.py", line 852, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/__main__.py", line 107, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/__main__.py", line 80, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/slither.py", line 150, in __init__
    self._init_parsing_and_analyses(kwargs.get("skip_analyze", False))
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/slither.py", line 160, in _init_parsing_and_analyses
    raise e
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/slither.py", line 156, in _init_parsing_and_analyses
    parser.parse_contracts()
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 542, in parse_contracts
    self._analyze_second_part(contracts_to_be_analyzed, libraries)
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 629, in _analyze_second_part
    self._analyze_struct_events(contract)
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 704, in _analyze_struct_events
    contract.analyze_events()
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/solc_parsing/declarations/contract.py", line 755, in analyze_events
    event_parser.analyze()  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/solc_parsing/declarations/event.py", line 54, in analyze
    elem_parser.analyze(self._slither_parser)
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/solc_parsing/variables/variable_declaration.py", line 212, in analyze
    self._variable.type = parse_type(self._elem_to_parse, caller_context)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/solc_parsing/solidity_types/type_parsing.py", line 430, in parse_type
    length = parse_expression(t["length"], caller_context)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 510, in parse_expression
    var, was_created = find_variable(value, caller_context, referenced_declaration)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/solc_parsing/expressions/find_variable.py", line 397, in find_variable
    direct_contracts, direct_functions, current_scope = _find_variable_init(caller_context)
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/solc_parsing/expressions/find_variable.py", line 333, in _find_variable_init
    raise SlitherError(
slither.exceptions.SlitherError: <class 'slither.solc_parsing.slither_compilation_unit_solc.SlitherCompilationUnitSolc'> (<slither.solc_parsing.slither_compilation_unit_solc.SlitherCompilationUnitSolc object at 0x7b96b39ce090> is not valid for find_variable
ERROR:root:Error:
ERROR:root:<class 'slither.solc_parsing.slither_compilation_unit_solc.SlitherCompilationUnitSolc'> (<slither.solc_parsing.slither_compilation_unit_solc.SlitherCompilationUnitSolc object at 0x7b96b39ce090> is not valid for find_variable
ERROR:root:Please report an issue to https://github.com/crytic/slither/issues
@Tiko7454 Tiko7454 added the bug-candidate Bugs reports that are not yet confirmed label Mar 11, 2024
@0xalpharush 0xalpharush added bug Something isn't working and removed bug-candidate Bugs reports that are not yet confirmed labels Mar 15, 2024
@0xalpharush 0xalpharush changed the title [Bug-Candidate]: Slither cannot parse event arguments from global scope [Bug]: Slither cannot parse event arguments from global scope Mar 15, 2024
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