<commit_before>class Proc
  def self.allocate
    raise TypeError, "allocator undefined for Proc"
  end

  def self.__allocate__
    Rubinius.primitive :proc_allocate
    raise PrimitiveFailure, "Proc#allocate primitive failed"
  end

  def call_prim(*args)
    Rubinius.primitive :proc_call
    raise PrimitiveFailure, "Proc#call primitive failed"
  end

  def call(*args, &block)
    if @ruby_method
      @ruby_method.call(*args, &block)
    else
      call_prim(*args, &block)
    end
  end

  def call_on_object(*args)
    Rubinius.primitive :proc_call_on_object
    raise PrimitiveFailure, "Proc#call_on_object primitive failed"
  end

  def lambda_style!
    @lambda = true
  end

  def lambda?
    !!@lambda
  end
end
class Proc
  def self.__from_block__(env)
    # The compiler must be fixed before this method can be removed.
    Rubinius::Mirror::Proc.from_block self, env
  end

  def self.new(*args)
    env = nil

    Rubinius.asm do
      push_block
      # assign a pushed block to the above local variable "env"
      # Note that "env" is indexed at 1, not 0. "args" is indexed at 0.
      set_local 1
    end

    unless env
      # Support for ancient pre-block-pass style:
      # def something; Proc.new; end
      # something { a_block } => Proc instance
      env = Rubinius::BlockEnvironment.of_sender

      unless env
        raise ArgumentError, "tried to create a Proc object without a block"
      end
    end

    block = Rubinius::Mirror::Proc.from_block self, env

    if block.class != self
      block = block.dup
      Rubinius::Unsafe.set_class(block, self)
    end

    Rubinius.asm(block, args) do |b, a|
      run b
      run a
      run b
      send_with_splat :initialize, 0, true
    end

    return block
  end

  attr_accessor :block
  attr_accessor :bound_method
  attr_accessor :ruby_method

  def binding
    bind = @block.to_binding
    bind.proc_environment = @block
    bind
  end

  def arity
    if @ruby_method
      return @ruby_method.arity
    elsif @bound_method
      arity = @bound_method.arity
      return arity < 0 ? -1 : arity
    end

    @block.arity
  end

  alias_method :===, :call

  def curry(curried_arity = nil)
    if lambda? && curried_arity
      if arity >= 0 && curried_arity != arity
        raise ArgumentError, "Wrong number of arguments (%i for %i)" % [
          curried_arity,
          arity
        ]
      end

      if arity < 0 && curried_arity < (-arity - 1)
        raise ArgumentError, "Wrong number of arguments (%i for %i)" % [
          curried_arity,
          -arity - 1
        ]
      end
    end<commit_msg>Fix Proc#arity.<commit_after>class Proc
  def self.allocate
    raise TypeError, "allocator undefined for Proc"
  end

  def self.__allocate__
    Rubinius.primitive :proc_allocate
    raise PrimitiveFailure, "Proc#allocate primitive failed"
  end

  def call_prim(*args)
    Rubinius.primitive :proc_call
    raise PrimitiveFailure, "Proc#call primitive failed"
  end

  def call(*args, &block)
    if @ruby_method
      @ruby_method.call(*args, &block)
    else
      call_prim(*args, &block)
    end
  end

  def call_on_object(*args)
    Rubinius.primitive :proc_call_on_object
    raise PrimitiveFailure, "Proc#call_on_object primitive failed"
  end

  def lambda_style!
    @lambda = true
  end

  def lambda?
    !!@lambda
  end
end
class Proc
  def self.__from_block__(env)
    # The compiler must be fixed before this method can be removed.
    Rubinius::Mirror::Proc.from_block self, env
  end

  def self.new(*args)
    env = nil

    Rubinius.asm do
      push_block
      # assign a pushed block to the above local variable "env"
      # Note that "env" is indexed at 1, not 0. "args" is indexed at 0.
      set_local 1
    end

    unless env
      # Support for ancient pre-block-pass style:
      # def something; Proc.new; end
      # something { a_block } => Proc instance
      env = Rubinius::BlockEnvironment.of_sender

      unless env
        raise ArgumentError, "tried to create a Proc object without a block"
      end
    end

    block = Rubinius::Mirror::Proc.from_block self, env

    if block.class != self
      block = block.dup
      Rubinius::Unsafe.set_class(block, self)
    end

    Rubinius.asm(block, args) do |b, a|
      run b
      run a
      run b
      send_with_splat :initialize, 0, true
    end

    return block
  end

  attr_accessor :block
  attr_accessor :bound_method
  attr_accessor :ruby_method

  def binding
    bind = @block.to_binding
    bind.proc_environment = @block
    bind
  end

  def arity
    if @ruby_method
      return @ruby_method.arity
    elsif @bound_method
      arity = @bound_method.arity
      return arity < 0 ? -1 : arity
    end

    arity = @block.arity
    return arity if self.lambda? ||
                    @block.compiled_code.splat ||
                    @block.compiled_code.total_args == arity

    -arity - 1
  end

  alias_method :===, :call

  def curry(curried_arity = nil)
    if lambda? && curried_arity
      if arity >= 0 && curried_arity != arity
        raise ArgumentError, "Wrong number of arguments (%i for %i)" % [
          curried_arity,
          arity
        ]
      end

      if arity < 0 && curried_arity < (-arity - 1)
        raise ArgumentError, "Wrong number of arguments (%i for %i)" % [
          curried_arity,
          -arity - 1
        ]
      end
    end
{'fraction_non_alphanumeric': 0.07966573816155989, 'fraction_numerical': 0.004271123491179201, 'mean_word_length': 2.3536737235367373, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7166487', 'n_tokens_mistral': 1790, 'n_tokens_neox': 1675, 'n_words': 522}