def _Procedure(self, ast):
        binders = [v.id for v in flatten(ast.variables)] # NOTE: this includes name

        _ClosureRecursion._Procedure(self, ast)

        # Take the free variable list, stick it in a set to make sure we don't
        # duplicate a variable, and then put it back in a list to make sure
        # it's got a defined ordering, which sets don't have
        free = list(set([v for v in S.free_variables(ast.body(), binders)
                        if v in self.env]))

        if free:
            bound = [S.Name(i % "_K%d") for i in range(len(free))]
            ast.variables = ast.variables + bound
            ast.parameters = S.substituted_expression(ast.parameters,
                                                      dict(zip(free, bound)))

            # Transform recursive calls of this procedure within its own body.
            recursive = _ClosureRecursion(self.env)
            self.env[ast.name().id] = bound
            ast.parameters = recursive.rewrite(ast.parameters)

            # Register rewrite for calls to this procedure in later
            # parts of the defining scope
            self.env[ast.name().id] = S.Closure([S.Name(x) for x in free],
                                                ast.name())
        # else:
#             self.locally_bound([ast.name()])

        return ast
dataset/ETHPy150Open bryancatanzaro/copperhead/copperhead/compiler/rewrites.py/_ClosureConverter._Procedure/swapped operands of `%`