class Parser::Ruby32

def try_declare_numparam(node)

def try_declare_numparam(node)
  name = node.children[0]
  if name =~ /\A_[1-9]\z/ && !static_env.declared?(name) && @context.in_dynamic_block?
    # definitely an implicit param
    location = node.loc.expression
    if max_numparam_stack.has_ordinary_params?
      diagnostic :error, :ordinary_param_defined, nil, [nil, location]
    end
    raw_max_numparam_stack = max_numparam_stack.stack.dup
    # ignore current block scope
    raw_max_numparam_stack.pop
    raw_max_numparam_stack.reverse_each do |outer_scope|
      if outer_scope[:static]
        # found an outer scope that can't have numparams
        # like def/class/etc
        break
      else
        outer_scope_has_numparams = outer_scope[:value] > 0
        if outer_scope_has_numparams
          diagnostic :error, :numparam_used_in_outer_scope, nil, [nil, location]
        else
          # for now it's ok, but an outer scope can also be a block
          # like proc { _1; proc { proc { proc { _2 }} }}
          # with numparams, so we need to continue
        end
      end
    end
    static_env.declare(name)
    max_numparam_stack.register(name[1].to_i)
    true
  else
    false
  end
end