gurudesh/pytracebugs huggingface dataset:
# Buggy code
def __str__(self):
    txt = str(self._called)
    if self.call_gas or self.call_value:
        gas = f"gas: {self.call_gas}" if self.call_gas else ""
        value = f"value: {self.call_value}" if self.call_value else ""
        if gas and value:
            txt += "{" + f"{gas}, {value}" + "}"
        elif gas:
            txt += "{" + f"{gas}" + "}"
        else:
            txt += "{" + f"{value}" + "}"
    return txt + "(" + ",".join([str(a) for a in self._arguments]) + ")"


# Traceback (AssertionError)
ERROR:root:Error in .
ERROR:root:Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/slither/__main__.py", line 606, in main_impl
printer_classes)
File "/usr/local/lib/python3.7/site-packages/slither/__main__.py", line 68, in process_all
compilation, args, detector_classes, printer_classes)
File "/usr/local/lib/python3.7/site-packages/slither/__main__.py", line 55, in process_single
**vars(args))
File "/usr/local/lib/python3.7/site-packages/slither/slither.py", line 86, in __init__
self._analyze_contracts()
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 254, in _analyze_contracts
self._analyze_third_part(contracts_to_be_analyzed, libraries)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 332, in _analyze_third_part
self._analyze_variables_modifiers_functions(contract)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 372, in _analyze_variables_modifiers_functions
contract.analyze_content_functions()
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/declarations/contract.py", line 291, in analyze_content_functions
function.analyze_content()
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/declarations/function.py", line 240, in analyze_content
node.analyze_expressions(self)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/cfg/node.py", line 31, in analyze_expressions
expression = parse_expression(self._unparsed_expression, caller_context)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 417, in parse_expression
return parse_call(expression, caller_context)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 271, in parse_call
called = parse_expression(expression['expression'], caller_context)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 422, in parse_expression
assert isinstance(called, MemberAccess)
AssertionError

# Fixed code
def __str__(self):
    txt = str(self._called)
    if self.call_gas or self.call_value:
        gas = f"gas: {self.call_gas}" if self.call_gas else ""
        value = f"value: {self.call_value}" if self.call_value else ""
        salt = f"salt: {self.call_salt}" if self.call_salt else ""
        if gas or value or salt:
            options = [gas, value, salt]
            txt += "{" + ",".join([o for o in options if o != ""]) + "}"
    return txt + "(" + ",".join([str(a) for a in self._arguments]) + ")"
# Buggy code
def __init__(self, contract_name):
    super(NewContract, self).__init__()
    self._contract_name = contract_name


# Traceback (AssertionError)
ERROR:root:Error in .
ERROR:root:Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/slither/__main__.py", line 606, in main_impl
printer_classes)
File "/usr/local/lib/python3.7/site-packages/slither/__main__.py", line 68, in process_all
compilation, args, detector_classes, printer_classes)
File "/usr/local/lib/python3.7/site-packages/slither/__main__.py", line 55, in process_single
**vars(args))
File "/usr/local/lib/python3.7/site-packages/slither/slither.py", line 86, in __init__
self._analyze_contracts()
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 254, in _analyze_contracts
self._analyze_third_part(contracts_to_be_analyzed, libraries)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 332, in _analyze_third_part
self._analyze_variables_modifiers_functions(contract)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 372, in _analyze_variables_modifiers_functions
contract.analyze_content_functions()
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/declarations/contract.py", line 291, in analyze_content_functions
function.analyze_content()
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/declarations/function.py", line 240, in analyze_content
node.analyze_expressions(self)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/cfg/node.py", line 31, in analyze_expressions
expression = parse_expression(self._unparsed_expression, caller_context)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 417, in parse_expression
return parse_call(expression, caller_context)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 271, in parse_call
called = parse_expression(expression['expression'], caller_context)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 422, in parse_expression
assert isinstance(called, MemberAccess)
AssertionError

# Fixed code
def __init__(self, contract_name):
    super(NewContract, self).__init__()
    self._contract_name = contract_name
    self._gas = None
    self._value = None
    self._salt = None
# Buggy code
def __init__(self, contract_name, lvalue):
    assert isinstance(contract_name, Constant)
    assert is_valid_lvalue(lvalue)
    super(NewContract, self).__init__()
    self._contract_name = contract_name
    # todo create analyze to add the contract instance
    self._lvalue = lvalue
    self._callid = None  # only used if gas/value != 0
    self._call_value = None


# Traceback (AssertionError)
ERROR:root:Error in .
ERROR:root:Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/slither/__main__.py", line 606, in main_impl
printer_classes)
File "/usr/local/lib/python3.7/site-packages/slither/__main__.py", line 68, in process_all
compilation, args, detector_classes, printer_classes)
File "/usr/local/lib/python3.7/site-packages/slither/__main__.py", line 55, in process_single
**vars(args))
File "/usr/local/lib/python3.7/site-packages/slither/slither.py", line 86, in __init__
self._analyze_contracts()
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 254, in _analyze_contracts
self._analyze_third_part(contracts_to_be_analyzed, libraries)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 332, in _analyze_third_part
self._analyze_variables_modifiers_functions(contract)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 372, in _analyze_variables_modifiers_functions
contract.analyze_content_functions()
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/declarations/contract.py", line 291, in analyze_content_functions
function.analyze_content()
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/declarations/function.py", line 240, in analyze_content
node.analyze_expressions(self)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/cfg/node.py", line 31, in analyze_expressions
expression = parse_expression(self._unparsed_expression, caller_context)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 417, in parse_expression
return parse_call(expression, caller_context)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 271, in parse_call
called = parse_expression(expression['expression'], caller_context)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 422, in parse_expression
assert isinstance(called, MemberAccess)
AssertionError

# Fixed code
def __init__(self, contract_name, lvalue):
    assert isinstance(contract_name, Constant)
    assert is_valid_lvalue(lvalue)
    super(NewContract, self).__init__()
    self._contract_name = contract_name
    # todo create analyze to add the contract instance
    self._lvalue = lvalue
    self._callid = None  # only used if gas/value != 0
    self._call_value = None
    self._call_salt = None
# Buggy code
def __str__(self):
    value = ""
    if self.call_value:
        value = "value:{}".format(self.call_value)
    args = [str(a) for a in self.arguments]
    return "{} = new {}({}) {}".format(
        self.lvalue, self.contract_name, ",".join(args), value
    )


# Traceback (AssertionError)
ERROR:root:Error in .
ERROR:root:Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/slither/__main__.py", line 606, in main_impl
printer_classes)
File "/usr/local/lib/python3.7/site-packages/slither/__main__.py", line 68, in process_all
compilation, args, detector_classes, printer_classes)
File "/usr/local/lib/python3.7/site-packages/slither/__main__.py", line 55, in process_single
**vars(args))
File "/usr/local/lib/python3.7/site-packages/slither/slither.py", line 86, in __init__
self._analyze_contracts()
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 254, in _analyze_contracts
self._analyze_third_part(contracts_to_be_analyzed, libraries)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 332, in _analyze_third_part
self._analyze_variables_modifiers_functions(contract)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 372, in _analyze_variables_modifiers_functions
contract.analyze_content_functions()
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/declarations/contract.py", line 291, in analyze_content_functions
function.analyze_content()
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/declarations/function.py", line 240, in analyze_content
node.analyze_expressions(self)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/cfg/node.py", line 31, in analyze_expressions
expression = parse_expression(self._unparsed_expression, caller_context)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 417, in parse_expression
return parse_call(expression, caller_context)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 271, in parse_call
called = parse_expression(expression['expression'], caller_context)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 422, in parse_expression
assert isinstance(called, MemberAccess)
AssertionError

# Fixed code
def __str__(self):
    options = ""
    if self.call_value:
        options = "value:{} ".format(self.call_value)
    if self.call_salt:
        options += "salt:{} ".format(self.call_salt)
    args = [str(a) for a in self.arguments]
    return "{} = new {}({}) {}".format(
        self.lvalue, self.contract_name, ",".join(args), options
    )
# Buggy code
def __init__(self, contract_name, lvalue):
    super(TmpNewContract, self).__init__()
    self._contract_name = contract_name
    self._lvalue = lvalue


# Traceback (AssertionError)
ERROR:root:Error in .
ERROR:root:Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/slither/__main__.py", line 606, in main_impl
printer_classes)
File "/usr/local/lib/python3.7/site-packages/slither/__main__.py", line 68, in process_all
compilation, args, detector_classes, printer_classes)
File "/usr/local/lib/python3.7/site-packages/slither/__main__.py", line 55, in process_single
**vars(args))
File "/usr/local/lib/python3.7/site-packages/slither/slither.py", line 86, in __init__
self._analyze_contracts()
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 254, in _analyze_contracts
self._analyze_third_part(contracts_to_be_analyzed, libraries)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 332, in _analyze_third_part
self._analyze_variables_modifiers_functions(contract)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 372, in _analyze_variables_modifiers_functions
contract.analyze_content_functions()
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/declarations/contract.py", line 291, in analyze_content_functions
function.analyze_content()
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/declarations/function.py", line 240, in analyze_content
node.analyze_expressions(self)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/cfg/node.py", line 31, in analyze_expressions
expression = parse_expression(self._unparsed_expression, caller_context)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 417, in parse_expression
return parse_call(expression, caller_context)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 271, in parse_call
called = parse_expression(expression['expression'], caller_context)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 422, in parse_expression
assert isinstance(called, MemberAccess)
AssertionError

# Fixed code
def __init__(self, contract_name, lvalue):
    super(TmpNewContract, self).__init__()
    self._contract_name = contract_name
    self._lvalue = lvalue
    self._call_value = None
    self._call_salt = None
# Buggy code
def _visit_call_expression(self, expression):
    self._visit_expression(expression.called)
    for arg in expression.arguments:
        if arg:
            self._visit_expression(arg)
    if expression.call_value:
        self._visit_expression(expression.call_value)
    if expression.call_gas:
        self._visit_expression(expression.call_gas)


# Traceback (AssertionError)
ERROR:root:Error in .
ERROR:root:Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/slither/__main__.py", line 606, in main_impl
printer_classes)
File "/usr/local/lib/python3.7/site-packages/slither/__main__.py", line 68, in process_all
compilation, args, detector_classes, printer_classes)
File "/usr/local/lib/python3.7/site-packages/slither/__main__.py", line 55, in process_single
**vars(args))
File "/usr/local/lib/python3.7/site-packages/slither/slither.py", line 86, in __init__
self._analyze_contracts()
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 254, in _analyze_contracts
self._analyze_third_part(contracts_to_be_analyzed, libraries)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 332, in _analyze_third_part
self._analyze_variables_modifiers_functions(contract)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 372, in _analyze_variables_modifiers_functions
contract.analyze_content_functions()
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/declarations/contract.py", line 291, in analyze_content_functions
function.analyze_content()
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/declarations/function.py", line 240, in analyze_content
node.analyze_expressions(self)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/cfg/node.py", line 31, in analyze_expressions
expression = parse_expression(self._unparsed_expression, caller_context)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 417, in parse_expression
return parse_call(expression, caller_context)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 271, in parse_call
called = parse_expression(expression['expression'], caller_context)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 422, in parse_expression
assert isinstance(called, MemberAccess)
AssertionError

# Fixed code
def _visit_call_expression(self, expression):
    self._visit_expression(expression.called)
    for arg in expression.arguments:
        if arg:
            self._visit_expression(arg)
    if expression.call_value:
        self._visit_expression(expression.call_value)
    if expression.call_gas:
        self._visit_expression(expression.call_gas)
    if expression.call_salt:
        self._visit_expression(expression.call_salt)
# Buggy code
def _post_new_contract(self, expression):
    val = TemporaryVariable(self._node)
    operation = TmpNewContract(expression.contract_name, val)
    operation.set_expression(expression)
    self._result.append(operation)
    set_val(expression, val)


# Traceback (AssertionError)
ERROR:root:Error in .
ERROR:root:Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/slither/__main__.py", line 606, in main_impl
printer_classes)
File "/usr/local/lib/python3.7/site-packages/slither/__main__.py", line 68, in process_all
compilation, args, detector_classes, printer_classes)
File "/usr/local/lib/python3.7/site-packages/slither/__main__.py", line 55, in process_single
**vars(args))
File "/usr/local/lib/python3.7/site-packages/slither/slither.py", line 86, in __init__
self._analyze_contracts()
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 254, in _analyze_contracts
self._analyze_third_part(contracts_to_be_analyzed, libraries)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 332, in _analyze_third_part
self._analyze_variables_modifiers_functions(contract)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 372, in _analyze_variables_modifiers_functions
contract.analyze_content_functions()
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/declarations/contract.py", line 291, in analyze_content_functions
function.analyze_content()
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/declarations/function.py", line 240, in analyze_content
node.analyze_expressions(self)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/cfg/node.py", line 31, in analyze_expressions
expression = parse_expression(self._unparsed_expression, caller_context)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 417, in parse_expression
return parse_call(expression, caller_context)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 271, in parse_call
called = parse_expression(expression['expression'], caller_context)
File "/usr/local/lib/python3.7/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 422, in parse_expression
assert isinstance(called, MemberAccess)
AssertionError

# Fixed code
def _post_new_contract(self, expression):
    val = TemporaryVariable(self._node)
    operation = TmpNewContract(expression.contract_name, val)
    operation.set_expression(expression)
    if expression.call_value:
        call_value = get(expression.call_value)
        operation.call_value = call_value
    if expression.call_salt:
        call_salt = get(expression.call_salt)
        operation.call_salt = call_salt

    self._result.append(operation)
    set_val(expression, val)
# Buggy code
def choose_printers(args, all_printer_classes):
    printers_to_run = []

    # disable default printer
    if args.printers_to_run is None:
        return []

    printers = {p.ARGUMENT: p for p in all_printer_classes}
    for p in args.printers_to_run.split(","):
        if p in printers:
            printers_to_run.append(printers[p])
        else:
            raise Exception("Error: {} is not a printer".format(p))
    return printers_to_run


# Traceback (AttributeError)
ERROR:root:Traceback (most recent call last):
File "c:\users\vyper\documents\github\slither\slither\__main__.py", line 512, in main_impl
extension = "*.sol" if not args.solc_ast else "*.json"
AttributeError: 'Namespace' object has no attribute 'solc_ast'

# Fixed code
def choose_printers(args, all_printer_classes):
    printers_to_run = []

    # disable default printer
    if args.printers_to_run is None:
        return []

    if args.printers_to_run == "all":
        return all_printer_classes

    printers = {p.ARGUMENT: p for p in all_printer_classes}
    for p in args.printers_to_run.split(","):
        if p in printers:
            printers_to_run.append(printers[p])
        else:
            raise Exception("Error: {} is not a printer".format(p))
    return printers_to_run
# Buggy code
def __init__(self, t, length):
    assert isinstance(t, Type)
    if length:
        if isinstance(length, int):
            length = Literal(length)
        assert isinstance(length, Expression)
    super(ArrayType, self).__init__()
    self._type = t
    self._length = length


# Traceback (AttributeError)
ERROR:root:Traceback (most recent call last):
File "c:\users\vyper\documents\github\slither\slither\__main__.py", line 278, in main_impl
(results_tmp, number_contracts_tmp) = process(filename, args, detector_classes, printer_classes)
File "c:\users\vyper\documents\github\slither\slither\__main__.py", line 40, in process
slither = Slither(filename, args.solc, args.disable_solc_warnings, args.solc_args, ast)
File "c:\users\vyper\documents\github\slither\slither\slither.py", line 41, in __init__
self._analyze_contracts()
File "c:\users\vyper\documents\github\slither\slither\solc_parsing\slitherSolc.py", line 210, in _analyze_contracts
self._analyze_third_part(contracts_to_be_analyzed, libraries)
File "c:\users\vyper\documents\github\slither\slither\solc_parsing\slitherSolc.py", line 294, in _analyze_third_part
self._analyze_variables_modifiers_functions(contract)
File "c:\users\vyper\documents\github\slither\slither\solc_parsing\slitherSolc.py", line 329, in _analyze_variables_modifiers_functions
contract.analyze_params_functions()
File "c:\users\vyper\documents\github\slither\slither\solc_parsing\declarations\contract.py", line 348, in analyze_params_functions
self._functions[function.full_name] = function
File "c:\users\vyper\documents\github\slither\slither\core\declarations\function.py", line 358, in full_name
name, parameters, _ = self.signature
File "c:\users\vyper\documents\github\slither\slither\core\declarations\function.py", line 341, in signature
return self.name, [str(x.type) for x in self.parameters], [str(x.type) for x in self.returns]
File "c:\users\vyper\documents\github\slither\slither\core\declarations\function.py", line 341, in <listcomp>
return self.name, [str(x.type) for x in self.parameters], [str(x.type) for x in self.returns]
File "c:\users\vyper\documents\github\slither\slither\core\solidity_types\array_type.py", line 25, in __str__
if isinstance(self._length.value, Variable) and self._length.value.is_constant:
AttributeError: 'BinaryOperation' object has no attribute 'value'

# Fixed code
def __init__(self, t, length):
    assert isinstance(t, Type)
    if length:
        if isinstance(length, int):
            length = Literal(length)
        assert isinstance(length, Expression)
        if not isinstance(length, Literal):
            cf = ConstantFolding(length)
            length = cf.result()
    super(ArrayType, self).__init__()
    self._type = t
    self._length = length
# Buggy code
def __init__(self, local_variable):
    assert isinstance(local_variable, LocalVariable)

    super(LocalIRVariable, self).__init__()

    # initiate ChildContract
    self.set_function(local_variable.function)

    # initiate Variable
    self._name = local_variable.name
    self._initial_expression = local_variable.expression
    self._type = local_variable.type
    self._initialized = local_variable.initialized
    self._visibility = local_variable.visibility
    self._is_constant = local_variable.is_constant

    # initiate LocalVariable
    self._location = self.location
    self._is_storage = self.is_storage

    self._index = 0

    # Additional field
    # points to state variables
    self._refers_to = set()

    # keep un-ssa version
    if isinstance(local_variable, LocalIRVariable):
        self._non_ssa_version = local_variable.non_ssa_version
    else:
        self._non_ssa_version = local_variable
    self._non_ssa_version = local_variable


# Traceback (TypeError)
ERROR:root:Traceback (most recent call last):
File "c:\users\vyper\documents\github\slither\slither\solc_parsing\slitherSolc.py", line 341, in _convert_to_slithir
contract.convert_expression_to_slithir()
File "c:\users\vyper\documents\github\slither\slither\solc_parsing\declarations\contract.py", line 386, in convert_expression_to_slithir
func.generate_slithir_ssa(all_ssa_state_variables_instances)
File "c:\users\vyper\documents\github\slither\slither\solc_parsing\declarations\function.py", line 935, in generate_slithir_ssa
add_ssa_ir(self, all_ssa_state_variables_instances)
File "c:\users\vyper\documents\github\slither\slither\slithir\utils\ssa.py", line 123, in add_ssa_ir
[])
File "c:\users\vyper\documents\github\slither\slither\slithir\utils\ssa.py", line 295, in generate_ssa_irs
visited)
File "c:\users\vyper\documents\github\slither\slither\slithir\utils\ssa.py", line 285, in generate_ssa_irs
new_ir.lvalue.add_refers_to(new_ir.rvalue)
File "c:\users\vyper\documents\github\slither\slither\slithir\variables\local_variable.py", line 56, in add_refers_to
self._refers_to.add(variable)
TypeError: unhashable type: 'Constant'

# Fixed code
def __init__(self, local_variable):
    assert isinstance(local_variable, LocalVariable)

    super(LocalIRVariable, self).__init__()

    # initiate ChildContract
    self.set_function(local_variable.function)

    # initiate Variable
    self._name = local_variable.name
    self._initial_expression = local_variable.expression
    self._type = local_variable.type
    self._initialized = local_variable.initialized
    self._visibility = local_variable.visibility
    self._is_constant = local_variable.is_constant

    # initiate LocalVariable
    self._location = local_variable.location
    self._is_storage = local_variable.is_storage

    self._index = 0

    # Additional field
    # points to state variables
    self._refers_to = set()

    # keep un-ssa version
    if isinstance(local_variable, LocalIRVariable):
        self._non_ssa_version = local_variable.non_ssa_version
    else:
        self._non_ssa_version = local_variable
    self._non_ssa_version = local_variable
# Buggy code
def __init__(self, lvalue, function, function_type):
    assert isinstance(function_type, FunctionType)
    assert isinstance(function, Variable)
    assert is_valid_lvalue(lvalue) or lvalue is None
    super(InternalDynamicCall, self).__init__()
    self._function = function
    self._function_type = function_type
    self._lvalue = lvalue


# Traceback (AttributeError)
ERROR:root:Traceback (most recent call last):
File "c:\users\vyper\documents\github\slither\slither\__main__.py", line 250, in main_impl
(results, number_contracts) = process(filename, args, detector_classes, printer_classes)
File "c:\users\vyper\documents\github\slither\slither\__main__.py", line 35, in process
slither = Slither(filename, args.solc, args.disable_solc_warnings, args.solc_args, ast)
File "c:\users\vyper\documents\github\slither\slither\slither.py", line 41, in __init__
self._analyze_contracts()
File "c:\users\vyper\documents\github\slither\slither\solc_parsing\slitherSolc.py", line 210, in _analyze_contracts
self._convert_to_slithir()
File "c:\users\vyper\documents\github\slither\slither\solc_parsing\slitherSolc.py", line 336, in _convert_to_slithir
contract.convert_expression_to_slithir()
File "c:\users\vyper\documents\github\slither\slither\solc_parsing\declarations\contract.py", line 367, in convert_expression_to_slithir
func.generate_slithir_and_analyze()
File "c:\users\vyper\documents\github\slither\slither\solc_parsing\declarations\function.py", line 927, in generate_slithir_and_analyze
node.slithir_generation()
File "c:\users\vyper\documents\github\slither\slither\core\cfg\node.py", line 508, in slithir_generation
self._find_read_write_call()
File "c:\users\vyper\documents\github\slither\slither\core\cfg\node.py", line 551, in _find_read_write_call
self._high_level_calls.append((ir.destination.type.type, ir.function))
AttributeError: 'FunctionType' object has no attribute 'type'

# Fixed code
def __init__(self, lvalue, function, function_type):
    assert isinstance(function_type, FunctionType)
    assert isinstance(function, Variable)
    assert is_valid_lvalue(lvalue) or lvalue is None
    super(InternalDynamicCall, self).__init__()
    self._function = function
    self._function_type = function_type
    self._lvalue = lvalue

    self._callid = None  # only used if gas/value != 0
    self._call_value = None
    self._call_gas = None
# Buggy code
def __str__(self):
    args = [str(a) for a in self.arguments]
    if not self.lvalue:
        lvalue = ""
    elif isinstance(self.lvalue.type, (list,)):
        lvalue = "{}({}) = ".format(
            self.lvalue, ",".join(str(x) for x in self.lvalue.type)
        )
    else:
        lvalue = "{}({}) = ".format(self.lvalue, self.lvalue.type)
    txt = "{}INTERNAL_DYNAMIC_CALL {}({})"
    return txt.format(lvalue, self.function.name, ",".join(args))


# Traceback (AttributeError)
ERROR:root:Traceback (most recent call last):
File "c:\users\vyper\documents\github\slither\slither\__main__.py", line 250, in main_impl
(results, number_contracts) = process(filename, args, detector_classes, printer_classes)
File "c:\users\vyper\documents\github\slither\slither\__main__.py", line 35, in process
slither = Slither(filename, args.solc, args.disable_solc_warnings, args.solc_args, ast)
File "c:\users\vyper\documents\github\slither\slither\slither.py", line 41, in __init__
self._analyze_contracts()
File "c:\users\vyper\documents\github\slither\slither\solc_parsing\slitherSolc.py", line 210, in _analyze_contracts
self._convert_to_slithir()
File "c:\users\vyper\documents\github\slither\slither\solc_parsing\slitherSolc.py", line 336, in _convert_to_slithir
contract.convert_expression_to_slithir()
File "c:\users\vyper\documents\github\slither\slither\solc_parsing\declarations\contract.py", line 367, in convert_expression_to_slithir
func.generate_slithir_and_analyze()
File "c:\users\vyper\documents\github\slither\slither\solc_parsing\declarations\function.py", line 927, in generate_slithir_and_analyze
node.slithir_generation()
File "c:\users\vyper\documents\github\slither\slither\core\cfg\node.py", line 508, in slithir_generation
self._find_read_write_call()
File "c:\users\vyper\documents\github\slither\slither\core\cfg\node.py", line 551, in _find_read_write_call
self._high_level_calls.append((ir.destination.type.type, ir.function))
AttributeError: 'FunctionType' object has no attribute 'type'

# Fixed code
def __str__(self):
    value = ""
    gas = ""
    args = [str(a) for a in self.arguments]
    if self.call_value:
        value = "value:{}".format(self.call_value)
    if self.call_gas:
        gas = "gas:{}".format(self.call_gas)
    if not self.lvalue:
        lvalue = ""
    elif isinstance(self.lvalue.type, (list,)):
        lvalue = "{}({}) = ".format(
            self.lvalue, ",".join(str(x) for x in self.lvalue.type)
        )
    else:
        lvalue = "{}({}) = ".format(self.lvalue, self.lvalue.type)
    txt = "{}INTERNAL_DYNAMIC_CALL {}({}) {} {}"
    return txt.format(lvalue, self.function.name, ",".join(args), value, gas)
# Buggy code
def __init__(self, t, length):
    assert isinstance(t, Type)
    if length:
        assert isinstance(length, Expression)
    super(ArrayType, self).__init__()
    self._type = t
    self._length = length


# Traceback (AssertionError)
ERROR:root:Traceback (most recent call last):
File "c:\users\vyper\documents\github\slither\slither\__main__.py", line 250, in main_impl
(results, number_contracts) = process(filename, args, detector_classes, printer_classes)
File "c:\users\vyper\documents\github\slither\slither\__main__.py", line 35, in process
slither = Slither(filename, args.solc, args.disable_solc_warnings, args.solc_args, ast)
File "c:\users\vyper\documents\github\slither\slither\slither.py", line 41, in __init__
self._analyze_contracts()
File "c:\users\vyper\documents\github\slither\slither\solc_parsing\slitherSolc.py", line 214, in _analyze_contracts
self._convert_to_slithir()
File "c:\users\vyper\documents\github\slither\slither\solc_parsing\slitherSolc.py", line 341, in _convert_to_slithir
contract.convert_expression_to_slithir()
File "c:\users\vyper\documents\github\slither\slither\solc_parsing\declarations\contract.py", line 367, in convert_expression_to_slithir
func.generate_slithir_and_analyze()
File "c:\users\vyper\documents\github\slither\slither\solc_parsing\declarations\function.py", line 927, in generate_slithir_and_analyze
node.slithir_generation()
File "c:\users\vyper\documents\github\slither\slither\core\cfg\node.py", line 506, in slithir_generation
self._irs = convert_expression(expression, self)
File "c:\users\vyper\documents\github\slither\slither\slithir\convert.py", line 734, in convert_expression
visitor = ExpressionToSlithIR(expression, node)
File "c:\users\vyper\documents\github\slither\slither\visitors\slithir\expression_to_slithir.py", line 70, in __init__
self._visit_expression(self.expression)
File "c:\users\vyper\documents\github\slither\slither\visitors\expression\expression.py", line 92, in _visit_expression
self._post_visit(expression)
File "c:\users\vyper\documents\github\slither\slither\visitors\expression\expression.py", line 275, in _post_visit
self._post_index_access(expression)
File "c:\users\vyper\documents\github\slither\slither\visitors\slithir\expression_to_slithir.py", line 163, in _post_index_access
operation = Index(val, left, right, expression.type)
File "c:\users\vyper\documents\github\slither\slither\slithir\operations\index.py", line 13, in __init__
assert is_valid_lvalue(left_variable) or left_variable == SolidityVariableComposed('msg.data')
AssertionError

# Fixed code
def __init__(self, t, length):
    assert isinstance(t, Type)
    if length:
        if isinstance(length, int):
            length = Literal(length)
        assert isinstance(length, Expression)
    super(ArrayType, self).__init__()
    self._type = t
    self._length = length
# Buggy code
def console_entry() -> None:
    main(None, sys.stdout, sys.stderr)


# Traceback (BrokenPipeError)
test.py:3: error: Unsupported operand types for + ("int" and "str")
Traceback (most recent call last):
File "/home/septatrix/.local/bin/mypy", line 8, in <module>
sys.exit(console_entry())
File "/home/septatrix/.local/lib/python3.8/site-packages/mypy/__main__.py", line 8, in console_entry
main(None, sys.stdout, sys.stderr)
File "mypy/main.py", line 122, in main
BrokenPipeError: [Errno 32] Broken pipe
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
BrokenPipeError: [Errno 32] Broken pipe

# Fixed code
def console_entry() -> None:
    try:
        main(None, sys.stdout, sys.stderr)
        sys.stdout.flush()
        sys.stderr.flush()
    except BrokenPipeError:
        # Python flushes standard streams on exit; redirect remaining output
        # to devnull to avoid another BrokenPipeError at shutdown
        devnull = os.open(os.devnull, os.O_WRONLY)
        os.dup2(devnull, sys.stdout.fileno())
        sys.exit(2)
# Buggy code
def flush_errors(new_messages: List[str], serious: bool) -> None:
    if options.pretty:
        new_messages = formatter.fit_in_terminal(new_messages)
    messages.extend(new_messages)
    f = stderr if serious else stdout
    try:
        for msg in new_messages:
            if options.color_output:
                msg = formatter.colorize(msg)
            f.write(msg + "\n")
        f.flush()
    except BrokenPipeError:
        sys.exit(2)


# Traceback (BrokenPipeError)
test.py:3: error: Unsupported operand types for + ("int" and "str")
Traceback (most recent call last):
File "/home/septatrix/.local/bin/mypy", line 8, in <module>
sys.exit(console_entry())
File "/home/septatrix/.local/lib/python3.8/site-packages/mypy/__main__.py", line 8, in console_entry
main(None, sys.stdout, sys.stderr)
File "mypy/main.py", line 122, in main
BrokenPipeError: [Errno 32] Broken pipe
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
BrokenPipeError: [Errno 32] Broken pipe

# Fixed code
def flush_errors(new_messages: List[str], serious: bool) -> None:
    if options.pretty:
        new_messages = formatter.fit_in_terminal(new_messages)
    messages.extend(new_messages)
    f = stderr if serious else stdout
    for msg in new_messages:
        if options.color_output:
            msg = formatter.colorize(msg)
        f.write(msg + "\n")
    f.flush()
# Buggy code
def visit_instance(self, typ: Instance) -> SnapshotItem:
    return (
        "Instance",
        typ.type.fullname(),
        snapshot_types(typ.args),
        None if typ.last_known_value is None else snapshot_type(typ.last_known_value),
    )


# Traceback (TypeError)
Traceback (most recent call last):
File "mypy/suggestions.py", line 212, in restore_after
File "mypy/suggestions.py", line 187, in suggest
File "mypy/suggestions.py", line 355, in get_suggestion
File "mypy/suggestions.py", line 325, in find_best
File "mypy/suggestions.py", line 524, in try_type
File "mypy/server/update.py", line 275, in trigger
File "mypy/server/update.py", line 804, in propagate_changes_using_dependencies
File "mypy/server/update.py", line 951, in reprocess_nodes
File "mypy/server/astdiff.py", line 160, in snapshot_symbol_table
File "mypy/server/astdiff.py", line 174, in snapshot_definition
File "mypy/server/astdiff.py", line 231, in snapshot_type
File "mypy/types.py", line 1061, in accept
File "mypy/server/astdiff.py", line 302, in visit_callable_type
File "mypy/server/astdiff.py", line 242, in snapshot_types
File "mypy/server/astdiff.py", line 231, in snapshot_type
File "mypy/types.py", line 1681, in accept
File "mypy/server/astdiff.py", line 325, in visit_union_type
TypeError: '<' not supported between instances of 'tuple' and 'NoneType'

# Fixed code
def visit_instance(self, typ: Instance) -> SnapshotItem:
    return (
        "Instance",
        encode_optional_str(typ.type.fullname()),
        snapshot_types(typ.args),
        ("None",)
        if typ.last_known_value is None
        else snapshot_type(typ.last_known_value),
    )
# Buggy code
def visit_callable_type(self, typ: CallableType) -> SnapshotItem:
    # FIX generics
    return (
        "CallableType",
        snapshot_types(typ.arg_types),
        snapshot_type(typ.ret_type),
        tuple(typ.arg_names),
        tuple(typ.arg_kinds),
        typ.is_type_obj(),
        typ.is_ellipsis_args,
    )


# Traceback (TypeError)
Traceback (most recent call last):
File "mypy/suggestions.py", line 212, in restore_after
File "mypy/suggestions.py", line 187, in suggest
File "mypy/suggestions.py", line 355, in get_suggestion
File "mypy/suggestions.py", line 325, in find_best
File "mypy/suggestions.py", line 524, in try_type
File "mypy/server/update.py", line 275, in trigger
File "mypy/server/update.py", line 804, in propagate_changes_using_dependencies
File "mypy/server/update.py", line 951, in reprocess_nodes
File "mypy/server/astdiff.py", line 160, in snapshot_symbol_table
File "mypy/server/astdiff.py", line 174, in snapshot_definition
File "mypy/server/astdiff.py", line 231, in snapshot_type
File "mypy/types.py", line 1061, in accept
File "mypy/server/astdiff.py", line 302, in visit_callable_type
File "mypy/server/astdiff.py", line 242, in snapshot_types
File "mypy/server/astdiff.py", line 231, in snapshot_type
File "mypy/types.py", line 1681, in accept
File "mypy/server/astdiff.py", line 325, in visit_union_type
TypeError: '<' not supported between instances of 'tuple' and 'NoneType'

# Fixed code
def visit_callable_type(self, typ: CallableType) -> SnapshotItem:
    # FIX generics
    return (
        "CallableType",
        snapshot_types(typ.arg_types),
        snapshot_type(typ.ret_type),
        tuple([encode_optional_str(name) for name in typ.arg_names]),
        tuple(typ.arg_kinds),
        typ.is_type_obj(),
        typ.is_ellipsis_args,
    )
# Buggy code
def visit_literal_type(self, typ: LiteralType) -> SnapshotItem:
    return ("LiteralType", typ.value, snapshot_type(typ.fallback))


# Traceback (TypeError)
Traceback (most recent call last):
File "mypy/suggestions.py", line 212, in restore_after
File "mypy/suggestions.py", line 187, in suggest
File "mypy/suggestions.py", line 355, in get_suggestion
File "mypy/suggestions.py", line 325, in find_best
File "mypy/suggestions.py", line 524, in try_type
File "mypy/server/update.py", line 275, in trigger
File "mypy/server/update.py", line 804, in propagate_changes_using_dependencies
File "mypy/server/update.py", line 951, in reprocess_nodes
File "mypy/server/astdiff.py", line 160, in snapshot_symbol_table
File "mypy/server/astdiff.py", line 174, in snapshot_definition
File "mypy/server/astdiff.py", line 231, in snapshot_type
File "mypy/types.py", line 1061, in accept
File "mypy/server/astdiff.py", line 302, in visit_callable_type
File "mypy/server/astdiff.py", line 242, in snapshot_types
File "mypy/server/astdiff.py", line 231, in snapshot_type
File "mypy/types.py", line 1681, in accept
File "mypy/server/astdiff.py", line 325, in visit_union_type
TypeError: '<' not supported between instances of 'tuple' and 'NoneType'

# Fixed code
def visit_literal_type(self, typ: LiteralType) -> SnapshotItem:
    return ("LiteralType", snapshot_type(typ.fallback), typ.value)
# Buggy code
def iterable_item_type(self, instance: Instance) -> Type:
    iterable = map_instance_to_supertype(
        instance, self.lookup_typeinfo("typing.Iterable")
    )
    item_type = iterable.args[0]
    if not isinstance(get_proper_type(item_type), AnyType):
        # This relies on 'map_instance_to_supertype' returning 'Iterable[Any]'
        # in case there is no explicit base class.
        return item_type
    # Try also structural typing.
    iter_type = get_proper_type(find_member("__iter__", instance, instance))
    if iter_type and isinstance(iter_type, CallableType):
        ret_type = get_proper_type(iter_type.ret_type)
        if isinstance(ret_type, Instance):
            iterator = map_instance_to_supertype(
                ret_type, self.lookup_typeinfo("typing.Iterator")
            )
            item_type = iterator.args[0]
    return item_type


# Traceback (RecursionError)
Traceback (most recent call last):
File "/home/zero323/anaconda3/bin/mypy", line 10, in <module>
sys.exit(console_entry())
...
RecursionError: maximum recursion depth exceeded while calling a Python object
foo.pyi:6: : note: use --pdb to drop into pdb

# Fixed code
def iterable_item_type(self, instance: Instance) -> Type:
    iterable = map_instance_to_supertype(
        instance, self.lookup_typeinfo("typing.Iterable")
    )
    item_type = iterable.args[0]
    if not isinstance(get_proper_type(item_type), AnyType):
        # This relies on 'map_instance_to_supertype' returning 'Iterable[Any]'
        # in case there is no explicit base class.
        return item_type
    # Try also structural typing.
    iter_type = get_proper_type(
        find_member("__iter__", instance, instance, is_operator=True)
    )
    if iter_type and isinstance(iter_type, CallableType):
        ret_type = get_proper_type(iter_type.ret_type)
        if isinstance(ret_type, Instance):
            iterator = map_instance_to_supertype(
                ret_type, self.lookup_typeinfo("typing.Iterator")
            )
            item_type = iterator.args[0]
    return item_type
# Buggy code
def unpack_callback_protocol(t: Instance) -> Optional[Type]:
    assert t.type.is_protocol
    if t.type.protocol_members == ["__call__"]:
        return find_member("__call__", t, t)
    return None


# Traceback (RecursionError)
Traceback (most recent call last):
File "/home/zero323/anaconda3/bin/mypy", line 10, in <module>
sys.exit(console_entry())
...
RecursionError: maximum recursion depth exceeded while calling a Python object
foo.pyi:6: : note: use --pdb to drop into pdb

# Fixed code
def unpack_callback_protocol(t: Instance) -> Optional[Type]:
    assert t.type.is_protocol
    if t.type.protocol_members == ["__call__"]:
        return find_member("__call__", t, t, is_operator=True)
    return None
# Buggy code
def incompatible_argument_note(
    self,
    original_caller_type: ProperType,
    callee_type: ProperType,
    context: Context,
    code: Optional[ErrorCode],
) -> None:
    if (
        isinstance(original_caller_type, (Instance, TupleType, TypedDictType))
        and isinstance(callee_type, Instance)
        and callee_type.type.is_protocol
    ):
        self.report_protocol_problems(
            original_caller_type, callee_type, context, code=code
        )
    if isinstance(callee_type, CallableType) and isinstance(
        original_caller_type, Instance
    ):
        call = find_member("__call__", original_caller_type, original_caller_type)
        if call:
            self.note_call(original_caller_type, call, context, code=code)


# Traceback (RecursionError)
Traceback (most recent call last):
File "/home/zero323/anaconda3/bin/mypy", line 10, in <module>
sys.exit(console_entry())
...
RecursionError: maximum recursion depth exceeded while calling a Python object
foo.pyi:6: : note: use --pdb to drop into pdb

# Fixed code
def incompatible_argument_note(
    self,
    original_caller_type: ProperType,
    callee_type: ProperType,
    context: Context,
    code: Optional[ErrorCode],
) -> None:
    if (
        isinstance(original_caller_type, (Instance, TupleType, TypedDictType))
        and isinstance(callee_type, Instance)
        and callee_type.type.is_protocol
    ):
        self.report_protocol_problems(
            original_caller_type, callee_type, context, code=code
        )
    if isinstance(callee_type, CallableType) and isinstance(
        original_caller_type, Instance
    ):
        call = find_member(
            "__call__", original_caller_type, original_caller_type, is_operator=True
        )
        if call:
            self.note_call(original_caller_type, call, context, code=code)