# Buggy code
def _parse_variable_definition(self, statement, node):
    try:
        local_var = LocalVariableSolc(statement)
        local_var.set_function(self)
        local_var.set_offset(statement["src"], self.contract.slither)

        self._variables[local_var.name] = local_var
        # local_var.analyze(self)

        new_node = self._new_node(NodeType.VARIABLE, statement["src"])
        new_node.add_variable_declaration(local_var)
        link_nodes(node, new_node)
        return new_node
    except MultipleVariablesDeclaration:
        # Custom handling of var (a,b) = .. style declaration
        if self.is_compact_ast:
            variables = statement["declarations"]
            count = len(variables)

            if statement["initialValue"]["nodeType"] == "TupleExpression":
                inits = statement["initialValue"]["components"]
                i = 0
                new_node = node
                for variable in variables:
                    init = inits[i]
                    src = variable["src"]
                    i = i + 1

                    new_statement = {
                        "nodeType": "VariableDefinitionStatement",
                        "src": src,
                        "declarations": [variable],
                        "initialValue": init,
                    }
                    new_node = self._parse_variable_definition(new_statement, new_node)

            else:
                # If we have
                # var (a, b) = f()
                # we can split in multiple declarations, without init
                # Then we craft one expression that does the assignment
                variables = []
                i = 0
                new_node = node
                for variable in statement["declarations"]:
                    i = i + 1
                    if variable:
                        src = variable["src"]
                        # Create a fake statement to be consistent
                        new_statement = {
                            "nodeType": "VariableDefinitionStatement",
                            "src": src,
                            "declarations": [variable],
                        }
                        variables.append(variable)

                        new_node = self._parse_variable_definition_init_tuple(
                            new_statement, i, new_node
                        )

                var_identifiers = []
                # craft of the expression doing the assignement
                for v in variables:
                    identifier = {
                        "nodeType": "Identifier",
                        "src": v["src"],
                        "name": v["name"],
                        "typeDescriptions": {
                            "typeString": v["typeDescriptions"]["typeString"]
                        },
                    }
                    var_identifiers.append(identifier)

                tuple_expression = {
                    "nodeType": "TupleExpression",
                    "src": statement["src"],
                    "components": var_identifiers,
                }

                expression = {
                    "nodeType": "Assignment",
                    "src": statement["src"],
                    "operator": "=",
                    "type": "tuple()",
                    "leftHandSide": tuple_expression,
                    "rightHandSide": statement["initialValue"],
                    "typeDescriptions": {"typeString": "tuple()"},
                }
                node = new_node
                new_node = self._new_node(NodeType.EXPRESSION, statement["src"])
                new_node.add_unparsed_expression(expression)
                link_nodes(node, new_node)

        else:
            count = 0
            children = statement[self.get_children("children")]
            child = children[0]
            while child[self.get_key()] == "VariableDeclaration":
                count = count + 1
                child = children[count]

            assert len(children) == (count + 1)
            tuple_vars = children[count]

            variables_declaration = children[0:count]
            i = 0
            new_node = node
            if tuple_vars[self.get_key()] == "TupleExpression":
                assert len(tuple_vars[self.get_children("children")]) == count
                for variable in variables_declaration:
                    init = tuple_vars[self.get_children("children")][i]
                    src = variable["src"]
                    i = i + 1
                    # Create a fake statement to be consistent
                    new_statement = {
                        self.get_key(): "VariableDefinitionStatement",
                        "src": src,
                        self.get_children("children"): [variable, init],
                    }

                    new_node = self._parse_variable_definition(new_statement, new_node)
            else:
                # If we have
                # var (a, b) = f()
                # we can split in multiple declarations, without init
                # Then we craft one expression that does the assignment
                assert tuple_vars[self.get_key()] in ["FunctionCall", "Conditional"]
                variables = []
                for variable in variables_declaration:
                    src = variable["src"]
                    i = i + 1
                    # Create a fake statement to be consistent
                    new_statement = {
                        self.get_key(): "VariableDefinitionStatement",
                        "src": src,
                        self.get_children("children"): [variable],
                    }
                    variables.append(variable)

                    new_node = self._parse_variable_definition_init_tuple(
                        new_statement, i, new_node
                    )
                var_identifiers = []
                # craft of the expression doing the assignement
                for v in variables:
                    identifier = {
                        self.get_key(): "Identifier",
                        "src": v["src"],
                        "attributes": {
                            "value": v["attributes"][self.get_key()],
                            "type": v["attributes"]["type"],
                        },
                    }
                    var_identifiers.append(identifier)

                expression = {
                    self.get_key(): "Assignment",
                    "src": statement["src"],
                    "attributes": {"operator": "=", "type": "tuple()"},
                    self.get_children("children"): [
                        {
                            self.get_key(): "TupleExpression",
                            "src": statement["src"],
                            self.get_children("children"): var_identifiers,
                        },
                        tuple_vars,
                    ],
                }
                node = new_node
                new_node = self._new_node(NodeType.EXPRESSION, statement["src"])
                new_node.add_unparsed_expression(expression)
                link_nodes(node, new_node)

        return new_node


# 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 _parse_variable_definition(self, statement, node):
    try:
        local_var = LocalVariableSolc(statement)
        local_var.set_function(self)
        local_var.set_offset(statement["src"], self.contract.slither)

        self._add_local_variable(local_var)
        # local_var.analyze(self)

        new_node = self._new_node(NodeType.VARIABLE, statement["src"])
        new_node.add_variable_declaration(local_var)
        link_nodes(node, new_node)
        return new_node
    except MultipleVariablesDeclaration:
        # Custom handling of var (a,b) = .. style declaration
        if self.is_compact_ast:
            variables = statement["declarations"]
            count = len(variables)

            if statement["initialValue"]["nodeType"] == "TupleExpression":
                inits = statement["initialValue"]["components"]
                i = 0
                new_node = node
                for variable in variables:
                    init = inits[i]
                    src = variable["src"]
                    i = i + 1

                    new_statement = {
                        "nodeType": "VariableDefinitionStatement",
                        "src": src,
                        "declarations": [variable],
                        "initialValue": init,
                    }
                    new_node = self._parse_variable_definition(new_statement, new_node)

            else:
                # If we have
                # var (a, b) = f()
                # we can split in multiple declarations, without init
                # Then we craft one expression that does the assignment
                variables = []
                i = 0
                new_node = node
                for variable in statement["declarations"]:
                    i = i + 1
                    if variable:
                        src = variable["src"]
                        # Create a fake statement to be consistent
                        new_statement = {
                            "nodeType": "VariableDefinitionStatement",
                            "src": src,
                            "declarations": [variable],
                        }
                        variables.append(variable)

                        new_node = self._parse_variable_definition_init_tuple(
                            new_statement, i, new_node
                        )

                var_identifiers = []
                # craft of the expression doing the assignement
                for v in variables:
                    identifier = {
                        "nodeType": "Identifier",
                        "src": v["src"],
                        "name": v["name"],
                        "typeDescriptions": {
                            "typeString": v["typeDescriptions"]["typeString"]
                        },
                    }
                    var_identifiers.append(identifier)

                tuple_expression = {
                    "nodeType": "TupleExpression",
                    "src": statement["src"],
                    "components": var_identifiers,
                }

                expression = {
                    "nodeType": "Assignment",
                    "src": statement["src"],
                    "operator": "=",
                    "type": "tuple()",
                    "leftHandSide": tuple_expression,
                    "rightHandSide": statement["initialValue"],
                    "typeDescriptions": {"typeString": "tuple()"},
                }
                node = new_node
                new_node = self._new_node(NodeType.EXPRESSION, statement["src"])
                new_node.add_unparsed_expression(expression)
                link_nodes(node, new_node)

        else:
            count = 0
            children = statement[self.get_children("children")]
            child = children[0]
            while child[self.get_key()] == "VariableDeclaration":
                count = count + 1
                child = children[count]

            assert len(children) == (count + 1)
            tuple_vars = children[count]

            variables_declaration = children[0:count]
            i = 0
            new_node = node
            if tuple_vars[self.get_key()] == "TupleExpression":
                assert len(tuple_vars[self.get_children("children")]) == count
                for variable in variables_declaration:
                    init = tuple_vars[self.get_children("children")][i]
                    src = variable["src"]
                    i = i + 1
                    # Create a fake statement to be consistent
                    new_statement = {
                        self.get_key(): "VariableDefinitionStatement",
                        "src": src,
                        self.get_children("children"): [variable, init],
                    }

                    new_node = self._parse_variable_definition(new_statement, new_node)
            else:
                # If we have
                # var (a, b) = f()
                # we can split in multiple declarations, without init
                # Then we craft one expression that does the assignment
                assert tuple_vars[self.get_key()] in ["FunctionCall", "Conditional"]
                variables = []
                for variable in variables_declaration:
                    src = variable["src"]
                    i = i + 1
                    # Create a fake statement to be consistent
                    new_statement = {
                        self.get_key(): "VariableDefinitionStatement",
                        "src": src,
                        self.get_children("children"): [variable],
                    }
                    variables.append(variable)

                    new_node = self._parse_variable_definition_init_tuple(
                        new_statement, i, new_node
                    )
                var_identifiers = []
                # craft of the expression doing the assignement
                for v in variables:
                    identifier = {
                        self.get_key(): "Identifier",
                        "src": v["src"],
                        "attributes": {
                            "value": v["attributes"][self.get_key()],
                            "type": v["attributes"]["type"],
                        },
                    }
                    var_identifiers.append(identifier)

                expression = {
                    self.get_key(): "Assignment",
                    "src": statement["src"],
                    "attributes": {"operator": "=", "type": "tuple()"},
                    self.get_children("children"): [
                        {
                            self.get_key(): "TupleExpression",
                            "src": statement["src"],
                            self.get_children("children"): var_identifiers,
                        },
                        tuple_vars,
                    ],
                }
                node = new_node
                new_node = self._new_node(NodeType.EXPRESSION, statement["src"])
                new_node.add_unparsed_expression(expression)
                link_nodes(node, new_node)

        return new_node