def computeStatement(self, constraint_collection):
        # This is very complex stuff, pylint: disable=R0912

        # TODO: Way too ugly to have global trace kinds just here, and needs to
        # be abstracted somehow. But for now we let it live here: pylint: disable=R0915

        # Let assignment source may re-compute first.
        constraint_collection.onExpression(self.getAssignSource())
        source = self.getAssignSource()

        # No assignment will occur, if the assignment source raises, so give up
        # on this, and return it as the only side effect.
        if source.willRaiseException(BaseException):
            result = makeStatementExpressionOnlyReplacementNode(
                expression = source,
                node       = self
            )

            return result, "new_raise", """\
Assignment raises exception in assigned value, removed assignment."""

        variable_ref = self.getTargetVariableRef()
        variable = variable_ref.getVariable()

        # Not allowed anymore at this point.
        assert variable is not None

        # Assigning from and to the same variable, can be optimized away
        # immediately, there is no point in doing it. Exceptions are of course
        # module variables that collide with built-in names.

        # TODO: The variable type checks ought to become unnecessary, as they
        # are to be a feature of the trace. Assigning from known assigned is
        # supposed to be possible to eliminate. If we get that wrong, we are
        # doing it wrong.
        if not variable.isModuleVariable() and \
             source.isExpressionVariableRef() and \
             source.getVariable() == variable:

            # A variable access that has a side effect, must be preserved,
            # so it can e.g. raise an exception, otherwise we can be fully
            # removed.
            if source.mayHaveSideEffects():
                result = makeStatementExpressionOnlyReplacementNode(
                    expression = source,
                    node       = self
                )

                return result, "new_statements", """\
Reduced assignment of variable '%s' from itself to mere access of it.""" % variable.getName()
            else:
                return None, "new_statements", """\
Removed assignment of variable '%s' from itself which is known to be defined.""" % variable.getName()

        # If the assignment source has side effects, we can simply evaluate them
        # beforehand, we have already visited and evaluated them before.
        if source.isExpressionSideEffects():
            statements = [
                makeStatementExpressionOnlyReplacementNode(
                    side_effect,
                    self
                )
                for side_effect in
                source.getSideEffects()
            ]

            statements.append(self)

            parent = self.parent
            result = makeStatementsSequenceReplacementNode(
                statements = statements,
                node       = self,
            )
            result.parent = parent

            # Need to update it.
            self.setAssignSource(source.getExpression())
            source = self.getAssignSource()

            constraint_collection.signalChange(
                tags       = "new_statements",
                message    = """\
Side effects of assignments promoted to statements.""",
                source_ref = self.getSourceReference()
            )

        # Set-up the trace to the trace collection, so future references will
        # find this assignment.
        self.variable_trace = constraint_collection.onVariableSet(
            assign_node = self
        )

        global_trace = variable.getGlobalVariableTrace()

        if global_trace is not None:
            provider = self.getParentVariableProvider()

            if not global_trace.hasAccessesOutsideOf(provider):
                last_trace = global_trace.getMatchingAssignTrace(self)

                if last_trace is not None:
                    if variable.isLocalVariable() or variable.isTempVariable():
                        if source.isCompileTimeConstant():

                            # Can safely forward propagate only non-mutable constants.
                            if not source.isMutable():
                                provider = self.getParentVariableProvider()

                                if variable.isTempVariable() or \
                                   (not provider.isExpressionClassBody() and \
                                    not provider.isUnoptimized()
                                    ):

                                    if last_trace.hasDefiniteUsages():
                                        self.variable_trace.setReplacementNode(
                                            lambda usage : source.makeClone()
                                        )
                                        propagated = True
                                    else:
                                        propagated = False

                                    if not last_trace.hasPotentialUsages() and not last_trace.hasNameUsages():
                                        if not last_trace.getPrevious().isUninitTrace():
                                            # TODO: We could well decide, if that's even necessary, but for now
                                            # the "StatementDelVariable" is tasked with that.
                                            result = StatementDelVariable(
                                                variable_ref = self.getTargetVariableRef(),
                                                tolerant     = True,
                                                source_ref   = self.getSourceReference()
                                            )
                                        else:
                                            result = None

                                        return (
                                            result,
                                            "new_statements",
                                            "Dropped %s assignment statement to '%s'." % (
                                               "propagated" if propagated else "dead",
                                               self.getTargetVariableRef().getVariableName()
                                            )
                                        )
                            else:
                                # Something might be possible still.

                                pass
                        elif Options.isExperimental() and \
                            source.isExpressionFunctionCreation() and \
                            source.getFunctionRef().getFunctionBody().isExpressionFunctionBody() and \
                            not source.getDefaults() and  \
                            not source.getKwDefaults() and \
                            not source.getAnnotations():
                            # TODO: These are very mutable, right?

                            provider = self.getParentVariableProvider()

                            if variable.isTempVariable() or \
                               (not provider.isUnoptimized() and \
                                not provider.isExpressionClassBody()):

                                if 1 <= last_trace.getDefiniteUsages() and \
                                   not last_trace.hasPotentialUsages() and \
                                   not last_trace.hasNameUsages():

                                    if last_trace.getDefiniteUsages() == 1:
                                        self.variable_trace.setReplacementNode(
                                            lambda usage : source.makeClone()
                                        )
                                        propagated = True
                                    else:
                                        propagated = False

                                    if not last_trace.getPrevious().isUninitTrace():
                                        # TODO: We could well decide, if that's even necessary.
                                        result = StatementDelVariable(
                                            variable_ref = self.getTargetVariableRef(),
                                            tolerant     = True,
                                            source_ref   = self.getSourceReference()
                                        )
                                    else:
                                        result = None

                                    return (
                                        result,
                                        "new_statements",
                                        "Dropped %s assignment statement to '%s'." % (
                                           "propagated" if propagated else "dead",
                                           self.getTargetVariableRef().getVariableName()
                                        )
                                    )
                        else:
                            # More cases thinkable.
                            pass

        return self, None, None
dataset/ETHPy150Open kayhayen/Nuitka/nuitka/nodes/AssignNodes.py/StatementAssignmentVariable.computeStatement/swapped operands of `<=`