def do_inline(src_fundef, args, dest_type_env, dest_block, result_var = None):
  arg_names = src_fundef.arg_names
  n_expected = len(arg_names)
  n_given = len(args)
  arg_str = ",".join(src_fundef.arg_names)
  assert n_expected == n_given, \
      "Function %s expects %d args (%s) but given %d (%s)" % \
      (src_fundef.name, n_expected, arg_str, n_given, args)

  rename_dict = {}

  def rename_var(old_name):
    t = src_fundef.type_env[old_name]
    new_name = names.refresh(old_name)
    new_var = Var(new_name, type = t)
    rename_dict[old_name] = new_var
    dest_type_env[new_name] = t

    return new_var

  for (old_formal, actual) in zip(arg_names, args):
    if (Var, Const) in actual.__class__:
      rename_dict[old_formal] = actual
    else:
      new_var = rename_var(old_formal)
      dest_block.append(Assign(new_var, actual))

  for old_name in src_fundef.type_env.iterkeys():
    if old_name not in arg_names:
      rename_var(old_name)

  new_body = subst_stmt_list(src_fundef.body, rename_dict)
  if result_var is None:
    result_var, new_body = \
        replace_return_with_var(new_body, dest_type_env, src_fundef.return_type)
  else:
    new_body = replace_returns(new_body, result_var)
  dest_block.extend(new_body)
  return result_var
dataset/ETHPy150Open iskandr/parakeet/parakeet/transforms/inline.py/do_inline/swapped operands of `in`