Skip to content

[Bug]: Vyper interfaces with default argument crash Slither #2375

Open
@trocher

Description

@trocher

Describe the issue:

When having a contract that does an external call to some function of another contract, if the interface defines this function with some default arguments, only if all arguments are supplied Slither does not crash.

Code example to reproduce the issue:

# @version 0.3.7


interface Pool:
    def price_oracle(i: uint256 = 0) -> uint256: view

@external
@view
def price(a:address):
    p: uint256 = Pool(a).price_oracle()

Version:

0.10.1

Relevant log output:

Traceback (most recent call last):
  File "/Users/trocher/.pyenv/versions/slither_prod/bin/slither", line 8, in <module>
    sys.exit(main())
  File "/Users/trocher/.pyenv/versions/slither_prod/lib/python3.8/site-packages/slither/__main__.py", line 746, in main
    main_impl(all_detector_classes=detectors, all_printer_classes=printers)
  File "/Users/trocher/.pyenv/versions/slither_prod/lib/python3.8/site-packages/slither/__main__.py", line 852, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/Users/trocher/.pyenv/versions/slither_prod/lib/python3.8/site-packages/slither/__main__.py", line 107, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/Users/trocher/.pyenv/versions/slither_prod/lib/python3.8/site-packages/slither/__main__.py", line 80, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
  File "/Users/trocher/.pyenv/versions/slither_prod/lib/python3.8/site-packages/slither/slither.py", line 150, in __init__
    self._init_parsing_and_analyses(kwargs.get("skip_analyze", False))
  File "/Users/trocher/.pyenv/versions/slither_prod/lib/python3.8/site-packages/slither/slither.py", line 170, in _init_parsing_and_analyses
    raise e
  File "/Users/trocher/.pyenv/versions/slither_prod/lib/python3.8/site-packages/slither/slither.py", line 166, in _init_parsing_and_analyses
    parser.analyze_contracts()
  File "/Users/trocher/.pyenv/versions/slither_prod/lib/python3.8/site-packages/slither/vyper_parsing/vyper_compilation_unit.py", line 63, in analyze_contracts
    self._convert_to_slithir()
  File "/Users/trocher/.pyenv/versions/slither_prod/lib/python3.8/site-packages/slither/vyper_parsing/vyper_compilation_unit.py", line 73, in _convert_to_slithir
    func.generate_slithir_and_analyze()
  File "/Users/trocher/.pyenv/versions/slither_prod/lib/python3.8/site-packages/slither/core/declarations/function.py", line 1772, in generate_slithir_and_analyze
    node.slithir_generation()
  File "/Users/trocher/.pyenv/versions/slither_prod/lib/python3.8/site-packages/slither/core/cfg/node.py", line 717, in slithir_generation
    self._irs = convert_expression(expression, self)  # type:ignore
  File "/Users/trocher/.pyenv/versions/slither_prod/lib/python3.8/site-packages/slither/slithir/convert.py", line 118, in convert_expression
    result = apply_ir_heuristics(result, node, is_solidity)
  File "/Users/trocher/.pyenv/versions/slither_prod/lib/python3.8/site-packages/slither/slithir/convert.py", line 2033, in apply_ir_heuristics
    irs = propagate_type_and_convert_call(irs, node)
  File "/Users/trocher/.pyenv/versions/slither_prod/lib/python3.8/site-packages/slither/slithir/convert.py", line 529, in propagate_type_and_convert_call
    new_ins = propagate_types(ins, node)
  File "/Users/trocher/.pyenv/versions/slither_prod/lib/python3.8/site-packages/slither/slithir/convert.py", line 649, in propagate_types
    return convert_type_of_high_and_internal_level_call(ir, t_type)
  File "/Users/trocher/.pyenv/versions/slither_prod/lib/python3.8/site-packages/slither/slithir/convert.py", line 1793, in convert_type_of_high_and_internal_level_call
    if isinstance(func.type, (MappingType, ArrayType)):
AttributeError: 'NoneType' object has no attribute 'type'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingvyper

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions