# Buggy code
def __init__(self, var):
    """
    A variable can be declared through a statement, or directly.
    If it is through a statement, the following children may contain
    the init value.
    It may be possible that the variable is declared through a statement,
    but the init value is declared at the VariableDeclaration children level
    """

    super(VariableDeclarationSolc, self).__init__()
    self._was_analyzed = False
    self._elem_to_parse = None
    self._initializedNotParsed = None

    self._is_compact_ast = False

    if "nodeType" in var:
        self._is_compact_ast = True
        nodeType = var["nodeType"]
        if nodeType in ["VariableDeclarationStatement", "VariableDefinitionStatement"]:
            if len(var["declarations"]) > 1:
                raise MultipleVariablesDeclaration
            init = None
            if "initialValue" in var:
                init = var["initialValue"]
            self._init_from_declaration(var["declarations"][0], init)
        elif nodeType == "VariableDeclaration":
            self._init_from_declaration(var, var["value"])
        else:
            logger.error("Incorrect variable declaration type {}".format(nodeType))
            exit(-1)

    else:
        nodeType = var["name"]

        if nodeType in ["VariableDeclarationStatement", "VariableDefinitionStatement"]:
            if len(var["children"]) == 2:
                init = var["children"][1]
            elif len(var["children"]) == 1:
                init = None
            elif len(var["children"]) > 2:
                raise MultipleVariablesDeclaration
            else:
                logger.error("Variable declaration without children?" + var)
                exit(-1)
            declaration = var["children"][0]
            self._init_from_declaration(declaration, init)
        elif nodeType == "VariableDeclaration":
            self._init_from_declaration(var, None)
        else:
            logger.error("Incorrect variable declaration type {}".format(nodeType))
            exit(-1)


# Traceback (AssertionError)
ERROR:root:Error in test.sol
ERROR:root:Traceback (most recent call last):
File "/Users/matt/anaconda3/lib/python3.7/site-packages/slither_analyzer-0.5.0-py3.7.egg/slither/__main__.py", line 250, in main_impl
(results, number_contracts) = process(filename, args, detector_classes, printer_classes)
File "/Users/matt/anaconda3/lib/python3.7/site-packages/slither_analyzer-0.5.0-py3.7.egg/slither/__main__.py", line 35, in process
slither = Slither(filename, args.solc, args.disable_solc_warnings, args.solc_args, ast)
File "/Users/matt/anaconda3/lib/python3.7/site-packages/slither_analyzer-0.5.0-py3.7.egg/slither/slither.py", line 41, in __init__
self._analyze_contracts()
File "/Users/matt/anaconda3/lib/python3.7/site-packages/slither_analyzer-0.5.0-py3.7.egg/slither/solc_parsing/slitherSolc.py", line 201, in _analyze_contracts
self._convert_to_slithir()
File "/Users/matt/anaconda3/lib/python3.7/site-packages/slither_analyzer-0.5.0-py3.7.egg/slither/solc_parsing/slitherSolc.py", line 327, in _convert_to_slithir
contract.convert_expression_to_slithir()
File "/Users/matt/anaconda3/lib/python3.7/site-packages/slither_analyzer-0.5.0-py3.7.egg/slither/solc_parsing/declarations/contract.py", line 374, in convert_expression_to_slithir
func.generate_slithir_ssa(all_ssa_state_variables_instances)
File "/Users/matt/anaconda3/lib/python3.7/site-packages/slither_analyzer-0.5.0-py3.7.egg/slither/solc_parsing/declarations/function.py", line 935, in generate_slithir_ssa
add_ssa_ir(self, all_ssa_state_variables_instances)
File "/Users/matt/anaconda3/lib/python3.7/site-packages/slither_analyzer-0.5.0-py3.7.egg/slither/slithir/utils/ssa.py", line 69, in add_ssa_ir
add_phi_origins(function.entry_point, init_definition, dict())
File "/Users/matt/anaconda3/lib/python3.7/site-packages/slither_analyzer-0.5.0-py3.7.egg/slither/slithir/utils/ssa.py", line 363, in add_phi_origins
add_phi_origins(succ, local_variables_definition, state_variables_definition)
File "/Users/matt/anaconda3/lib/python3.7/site-packages/slither_analyzer-0.5.0-py3.7.egg/slither/slithir/utils/ssa.py", line 363, in add_phi_origins
add_phi_origins(succ, local_variables_definition, state_variables_definition)
File "/Users/matt/anaconda3/lib/python3.7/site-packages/slither_analyzer-0.5.0-py3.7.egg/slither/slithir/utils/ssa.py", line 363, in add_phi_origins
add_phi_origins(succ, local_variables_definition, state_variables_definition)
[Previous line repeated 2 more times]
File "/Users/matt/anaconda3/lib/python3.7/site-packages/slither_analyzer-0.5.0-py3.7.egg/slither/slithir/utils/ssa.py", line 356, in add_phi_origins
phi_node.add_phi_origin_local_variable(variable, n)
File "/Users/matt/anaconda3/lib/python3.7/site-packages/slither_analyzer-0.5.0-py3.7.egg/slither/core/cfg/node.py", line 215, in add_phi_origin_local_variable
assert v == variable
AssertionError

# Fixed code
def __init__(self, var):
    """
    A variable can be declared through a statement, or directly.
    If it is through a statement, the following children may contain
    the init value.
    It may be possible that the variable is declared through a statement,
    but the init value is declared at the VariableDeclaration children level
    """

    super(VariableDeclarationSolc, self).__init__()
    self._was_analyzed = False
    self._elem_to_parse = None
    self._initializedNotParsed = None

    self._is_compact_ast = False

    self._reference_id = None

    if "nodeType" in var:
        self._is_compact_ast = True
        nodeType = var["nodeType"]
        if nodeType in ["VariableDeclarationStatement", "VariableDefinitionStatement"]:
            if len(var["declarations"]) > 1:
                raise MultipleVariablesDeclaration
            init = None
            if "initialValue" in var:
                init = var["initialValue"]
            self._init_from_declaration(var["declarations"][0], init)
        elif nodeType == "VariableDeclaration":
            self._init_from_declaration(var, var["value"])
        else:
            logger.error("Incorrect variable declaration type {}".format(nodeType))
            exit(-1)

    else:
        nodeType = var["name"]

        if nodeType in ["VariableDeclarationStatement", "VariableDefinitionStatement"]:
            if len(var["children"]) == 2:
                init = var["children"][1]
            elif len(var["children"]) == 1:
                init = None
            elif len(var["children"]) > 2:
                raise MultipleVariablesDeclaration
            else:
                logger.error("Variable declaration without children?" + var)
                exit(-1)
            declaration = var["children"][0]
            self._init_from_declaration(declaration, init)
        elif nodeType == "VariableDeclaration":
            self._init_from_declaration(var, None)
        else:
            logger.error("Incorrect variable declaration type {}".format(nodeType))
            exit(-1)