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]: Vyper for loop over a constant or immutable iterable fails #2195

Open
trocher opened this issue Oct 19, 2023 · 0 comments
Open

[Bug]: Vyper for loop over a constant or immutable iterable fails #2195

trocher opened this issue Oct 19, 2023 · 0 comments
Labels
bug Something isn't working vyper

Comments

@trocher
Copy link

trocher commented Oct 19, 2023

Describe the issue:

Similar to #2194, looping over a constant or immutable iterable makes Slither fail.

Likely due to:

As it assumes a Name AST node must be a local variable but could also be an immutable or a constant.

Code example to reproduce the issue:

a:immutable(uint256[3])
@external
def __init__():
    a = [1,2,3]

@external
def foo():
    for i in a:
        pass

Version:

0.10.0

Relevant log output:

Traceback (most recent call last):
  File "/home/csdocker/.local/bin/slither", line 8, in <module>
    sys.exit(main())
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/__main__.py", line 727, in main
    main_impl(all_detector_classes=detectors, all_printer_classes=printers)
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/__main__.py", line 833, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/__main__.py", line 107, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/__main__.py", line 80, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/slither.py", line 144, in __init__
    self._init_parsing_and_analyses(kwargs.get("skip_analyze", False))
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/slither.py", line 164, in _init_parsing_and_analyses
    raise e
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/slither.py", line 160, in _init_parsing_and_analyses
    parser.analyze_contracts()
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/vyper_parsing/vyper_compilation_unit.py", line 61, in analyze_contracts
    contract_parser.analyze()
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/vyper_parsing/declarations/contract.py", line 521, in analyze
    function.analyze_content()
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/vyper_parsing/declarations/function.py", line 186, in analyze_content
    self._parse_cfg(body)
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/vyper_parsing/declarations/function.py", line 523, in _parse_cfg
    curr_node = parse_statement(curr_node, expr)
  File "/home/csdocker/.local/pipx/venvs/slither-analyzer/lib/python3.10/site-packages/slither/vyper_parsing/declarations/function.py", line 342, in parse_statement
    loop_iterator = list(
IndexError: list index out of range
@trocher trocher added the bug-candidate Bugs reports that are not yet confirmed label Oct 19, 2023
@0xalpharush 0xalpharush added bug Something isn't working and removed bug-candidate Bugs reports that are not yet confirmed labels Oct 19, 2023
@0xalpharush 0xalpharush changed the title [Bug-Candidate]: Vyper for loop over a constant or immutable iterable fails [Bug]: Vyper for loop over a constant or immutable iterable fails Oct 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 vyper
Projects
None yet
Development

No branches or pull requests

2 participants