Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c (C)

Code before:
                                                             elementLen,
                                                             targetIndex,
                                                             depth-1,
                                                             ECMA_VALUE_UNDEFINED,
                                                             ECMA_VALUE_UNDEFINED);
        ecma_deref_object (element_obj);
      }
      else
      {
        ecma_value_t element_temp = ecma_builtin_helper_def_prop_by_index (ecma_get_object_from_value (target),
                                                                           targetIndex,
                                                                           element,
                                                                      ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);

        ecma_free_value (element);
        if (ECMA_IS_VALUE_ERROR (element_temp))
        {
          return element_temp;
        }

        targetIndex++;
      }
    }
    sourceIndex++;
  }
  return targetIndex;
} /* ecma_builtin_array_flatten_into_array */

/**
 * The Array.prototype object's 'flat' routine
 *
 * See also:
 *          ECMA-262 v10, 22.1.3.10
 *
 * @return ecma value
 *         Returned value must be freed with ecma_free_value.
 */
static ecma_value_t
ecma_builtin_array_prototype_object_flat (const ecma_value_t args[], /**< arguments list */
                                                ecma_length_t args_number, /**< number of arguments */
                                                ecma_object_t *obj_p, /**< array object */
                                                uint32_t len) /**< array object's length */
{
  ecma_number_t depthNum = 1;
  if (args_number > 0)
  {
    if (ECMA_IS_VALUE_ERROR (ecma_op_to_integer (args[0], &depthNum)))
    {
      return ECMA_VALUE_ERROR;
    }
  }

Review comment (suggestion):
The return value of the method should be `ecma_value_t`, and at this point you should return with `ecma_make_uin32t_value`.

Code after:
    }
  }

  /* 8. */
  while (from_index < len)
  {
    ecma_value_t element = ecma_op_object_get_by_index (obj_p, from_index);

    if (ECMA_IS_VALUE_ERROR (element))
    {
      return element;
    }

    if (ecma_op_same_value_zero (element, args[0]))
    {
      ecma_free_value (element);
      return ECMA_VALUE_TRUE;
    }

    ecma_free_value (element);
    from_index++;
  }

  /* 9. */
  return ECMA_VALUE_FALSE;
} /* ecma_builtin_array_prototype_includes */

/**
 * Abstract operation: FlattenIntoArray
 *
 * See also:
 *          ECMA-262 v10, 22.1.3.10.1
 *
 * @return  ECMA_VALUE_ERROR -if the operation fails
 *          ecma value which contains target_index
 */
static ecma_value_t
ecma_builtin_array_flatten_into_array (ecma_value_t target, /**< target will contains source's elements  */
                                       ecma_object_t *source, /**< source object */
                                       ecma_length_t source_len, /**< source object length */
                                       ecma_length_t start, /**< remaining recursion depth */
                                       ecma_number_t depth, /**< start index offset */
                                       ecma_value_t mapped_value, /**< mapped value  */
                                       ecma_value_t thisArg) /**< this arg */
{
  /* 7. */
  ecma_length_t target_index = start;

  /* 9. */
  for (ecma_length_t source_index = 0; source_index < source_len; source_index++)
  {