# Buggy code
def _init_from_declaration(self, var, init):
    if self._is_compact_ast:
        attributes = var
        self._typeName = attributes["typeDescriptions"]["typeString"]
    else:
        assert len(var["children"]) <= 2
        assert var["name"] == "VariableDeclaration"

        attributes = var["attributes"]
        self._typeName = attributes["type"]

    self._name = attributes["name"]
    self._arrayDepth = 0
    self._isMapping = False
    self._mappingFrom = None
    self._mappingTo = False
    self._initial_expression = None
    self._type = None

    if "constant" in attributes:
        self._is_constant = attributes["constant"]

    self._analyze_variable_attributes(attributes)

    if self._is_compact_ast:
        if var["typeName"]:
            self._elem_to_parse = var["typeName"]
        else:
            self._elem_to_parse = UnknownType(var["typeDescriptions"]["typeString"])
    else:
        if not var["children"]:
            # It happens on variable declared inside loop declaration
            try:
                self._type = ElementaryType(self._typeName)
                self._elem_to_parse = None
            except NonElementaryType:
                self._elem_to_parse = UnknownType(self._typeName)
        else:
            self._elem_to_parse = var["children"][0]

    if self._is_compact_ast:
        self._initializedNotParsed = init
        if init:
            self._initialized = True
    else:
        if init:  # there are two way to init a var local in the AST
            assert len(var["children"]) <= 1
            self._initialized = True
            self._initializedNotParsed = init
        elif len(var["children"]) in [0, 1]:
            self._initialized = False
            self._initializedNotParsed = []
        else:
            assert len(var["children"]) == 2
            self._initialized = True
            self._initializedNotParsed = var["children"][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_from_declaration(self, var, init):
    if self._is_compact_ast:
        attributes = var
        self._typeName = attributes["typeDescriptions"]["typeString"]
    else:
        assert len(var["children"]) <= 2
        assert var["name"] == "VariableDeclaration"

        attributes = var["attributes"]
        self._typeName = attributes["type"]

    self._name = attributes["name"]
    self._arrayDepth = 0
    self._isMapping = False
    self._mappingFrom = None
    self._mappingTo = False
    self._initial_expression = None
    self._type = None

    # Only for comapct ast format
    # the id can be used later if referencedDeclaration
    # is provided
    if "id" in var:
        self._reference_id = var["id"]

    if "constant" in attributes:
        self._is_constant = attributes["constant"]

    self._analyze_variable_attributes(attributes)

    if self._is_compact_ast:
        if var["typeName"]:
            self._elem_to_parse = var["typeName"]
        else:
            self._elem_to_parse = UnknownType(var["typeDescriptions"]["typeString"])
    else:
        if not var["children"]:
            # It happens on variable declared inside loop declaration
            try:
                self._type = ElementaryType(self._typeName)
                self._elem_to_parse = None
            except NonElementaryType:
                self._elem_to_parse = UnknownType(self._typeName)
        else:
            self._elem_to_parse = var["children"][0]

    if self._is_compact_ast:
        self._initializedNotParsed = init
        if init:
            self._initialized = True
    else:
        if init:  # there are two way to init a var local in the AST
            assert len(var["children"]) <= 1
            self._initialized = True
            self._initializedNotParsed = init
        elif len(var["children"]) in [0, 1]:
            self._initialized = False
            self._initializedNotParsed = []
        else:
            assert len(var["children"]) == 2
            self._initialized = True
            self._initializedNotParsed = var["children"][1]