ronantakizawa/codereview-bench huggingface dataset:
Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/builtin-objects/ecma-builtin-object.c (C)

Code before:
 * The Object object's 'fromEntries' routine
 *
 * See also:
 *          ECMA-262 v10, 19.1.2.7
 * @return ecma value
 *         Returned value must be freed with ecma_free_value.
 */
static ecma_value_t
ecma_builtin_object_from_entries (ecma_value_t iterator) /**< object's iterator */
{
  /* 1. */
  if (ECMA_IS_VALUE_ERROR (ecma_op_check_object_coercible (iterator)))
  {
    return ECMA_VALUE_ERROR;
  }
  /* 2 */
  ecma_object_t *object_prototype_p = ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE);
  ecma_object_t *obj_p = ecma_create_object (object_prototype_p, 0, ECMA_OBJECT_TYPE_GENERAL);

  /* 6 */
  ecma_value_t next_method;
  ecma_value_t result = ecma_op_get_iterator (iterator, ECMA_VALUE_SYNC_ITERATOR, &next_method);

  if (ECMA_IS_VALUE_ERROR (result))
  {
    ecma_free_value (next_method);
    ecma_deref_object (obj_p);
    return result;
  }

  const ecma_value_t temp_iterator = result;

  while (true)
  {
    result = ecma_op_iterator_step (temp_iterator, next_method);

    if (ECMA_IS_VALUE_ERROR (result))
    {
      goto cleanup_iterator;
    }

    if (ecma_is_value_false (result))
    {
      break;
    }

    const ecma_value_t next = result;
    result = ecma_op_iterator_value (next);
    ecma_free_value (next);

    if (ECMA_IS_VALUE_ERROR (result))

Review comment (suggestion):
This should be free, since `next_method` is initialized only if the result of `GetIterator` operation is not an abrupt completion. Please add a testcase as well.

Code after:
 * The Object object's 'fromEntries' routine
 *
 * See also:
 *          ECMA-262 v10, 19.1.2.7
 * @return ecma value
 *         Returned value must be freed with ecma_free_value.
 */
static ecma_value_t
ecma_builtin_object_from_entries (ecma_value_t iterator) /**< object's iterator */
{
  JERRY_ASSERT (ecma_op_check_object_coercible (iterator));
  /* 2 */
  ecma_object_t *object_prototype_p = ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE);
  ecma_object_t *obj_p = ecma_create_object (object_prototype_p, 0, ECMA_OBJECT_TYPE_GENERAL);

  /* 6.a */
  ecma_value_t next_method;
  ecma_value_t result = ecma_op_get_iterator (iterator, ECMA_VALUE_SYNC_ITERATOR, &next_method);

  if (ECMA_IS_VALUE_ERROR (result))
  {
    ecma_deref_object (obj_p);
    return result;
  }

  const ecma_value_t original_iterator = result;

  /* 6.b */
  while (true)
  {
    /* 6.a.i */
    result = ecma_op_iterator_step (original_iterator, next_method);

    if (ECMA_IS_VALUE_ERROR (result))
    {
      goto cleanup_iterator;
    }

    /* 6.a.ii */
    if (ecma_is_value_false (result))
    {
      break;
    }

    /* 6.a.iii */
    const ecma_value_t next = result;
    result = ecma_op_iterator_value (next);
    ecma_free_value (next);

    if (ECMA_IS_VALUE_ERROR (result))
    {
Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c (C)

Code before:
            goto cleanup_replace;
          }

          ecma_string_t *const result_str_p = ecma_op_to_string (result);
          ecma_free_value (result);

          if (result_str_p == NULL)
          {
            ecma_stringbuilder_destroy (&replace_ctx.builder);
            result = ECMA_VALUE_ERROR;
            goto cleanup_replace;
          }

          ecma_stringbuilder_append (&replace_ctx.builder, result_str_p);
          ecma_deref_ecma_string (result_str_p);
        }
        else
        {
          replace_ctx.matched_p = curr_p;
          replace_ctx.match_byte_pos = replace_all ? (lit_utf8_size_t) (curr_p - replace_ctx.string_p) : byte_offset;

          ecma_builtin_replace_substitute (&replace_ctx);
        }

        if (replace_all)
        {
          if (last_match_end_p == input_end_p)
          {
            break;
          }
          else
          {
            curr_p = last_match_end_p;

            if (search_size != 0)
            {
              lit_utf8_decr (&curr_p);
            }
          }
        }
        else
        {
          const lit_utf8_byte_t *const match_end_p = curr_p + search_size;
          ecma_stringbuilder_append_raw (&replace_ctx.builder,
                                        match_end_p,
                                        (lit_utf8_size_t) (input_end_p - match_end_p));
          result_string_p = ecma_stringbuilder_finalize (&replace_ctx.builder);
          break;
        }
      }
    }

Review comment (suggestion):
```c
if (!replace_all)
{
  break;
}

curr_p = last_match_end_p;
continue;
```

Code after:
          ecma_string_t *const result_str_p = ecma_op_to_string (result);
          ecma_free_value (result);

          if (result_str_p == NULL)
          {
            ecma_stringbuilder_destroy (&replace_ctx.builder);
            result = ECMA_VALUE_ERROR;
            goto cleanup_replace;
          }

          ecma_stringbuilder_append (&replace_ctx.builder, result_str_p);
          ecma_deref_ecma_string (result_str_p);
        }
        else
        {
          replace_ctx.matched_p = curr_p;
          replace_ctx.match_byte_pos = (lit_utf8_size_t) (curr_p - replace_ctx.string_p);

          ecma_builtin_replace_substitute (&replace_ctx);
        }

        if (!replace_all
            || last_match_end_p == input_end_p)
        {
          break;
        }

        if (search_size != 0)
        {
          curr_p = last_match_end_p;
          pos += search_length;
          continue;
        }
      }

      pos++;
      lit_utf8_incr (&curr_p);
    }

    ecma_stringbuilder_append_raw (&replace_ctx.builder,
                                    last_match_end_p,
                                    (lit_utf8_size_t) (input_end_p - last_match_end_p));
    result_string_p = ecma_stringbuilder_finalize (&replace_ctx.builder);

  }

  if (result_string_p == NULL)
  {
    ecma_ref_ecma_string (input_str_p);
    result_string_p = input_str_p;
  }
Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c (C)

Code before:

          if (result_str_p == NULL)
          {
            ecma_stringbuilder_destroy (&replace_ctx.builder);
            result = ECMA_VALUE_ERROR;
            goto cleanup_replace;
          }

          ecma_stringbuilder_append (&replace_ctx.builder, result_str_p);
          ecma_deref_ecma_string (result_str_p);
        }
        else
        {
          replace_ctx.matched_p = curr_p;
          replace_ctx.match_byte_pos = (lit_utf8_size_t) (curr_p - replace_ctx.string_p);

          ecma_builtin_replace_substitute (&replace_ctx);
        }

        if (!replace_all
            || last_match_end_p == input_end_p)
        {
          break;
        }

        curr_p = last_match_end_p;

        if (search_size != 0)
        {
          continue;
        }
      }

      pos++;
      lit_utf8_incr (&curr_p);
    }

    ecma_stringbuilder_append_raw (&replace_ctx.builder,
                                    last_match_end_p,
                                    (lit_utf8_size_t) (input_end_p - last_match_end_p));
    result_string_p = ecma_stringbuilder_finalize (&replace_ctx.builder);

  }

  if (result_string_p == NULL)
  {
    ecma_ref_ecma_string (input_str_p);
    result_string_p = input_str_p;
  }

  result = ecma_make_string_value (result_string_p);

Review comment (suggestion):
This could be moved into the `search_size != 0` block below, otherwise `last_match_end_p` is equal to `curr_p` anyways.

Code after:
          ecma_free_value (result);

          if (result_str_p == NULL)
          {
            ecma_stringbuilder_destroy (&replace_ctx.builder);
            result = ECMA_VALUE_ERROR;
            goto cleanup_replace;
          }

          ecma_stringbuilder_append (&replace_ctx.builder, result_str_p);
          ecma_deref_ecma_string (result_str_p);
        }
        else
        {
          replace_ctx.matched_p = curr_p;
          replace_ctx.match_byte_pos = (lit_utf8_size_t) (curr_p - replace_ctx.string_p);

          ecma_builtin_replace_substitute (&replace_ctx);
        }

        if (!replace_all
            || last_match_end_p == input_end_p)
        {
          break;
        }

        if (search_size != 0)
        {
          curr_p = last_match_end_p;
          pos += search_length;
          continue;
        }
      }

      pos++;
      lit_utf8_incr (&curr_p);
    }

    ecma_stringbuilder_append_raw (&replace_ctx.builder,
                                    last_match_end_p,
                                    (lit_utf8_size_t) (input_end_p - last_match_end_p));
    result_string_p = ecma_stringbuilder_finalize (&replace_ctx.builder);

  }

  if (result_string_p == NULL)
  {
    ecma_ref_ecma_string (input_str_p);
    result_string_p = input_str_p;
  }
Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c (C)

Code before:
            ecma_stringbuilder_destroy (&replace_ctx.builder);
            result = ECMA_VALUE_ERROR;
            goto cleanup_replace;
          }

          ecma_stringbuilder_append (&replace_ctx.builder, result_str_p);
          ecma_deref_ecma_string (result_str_p);
        }
        else
        {
          replace_ctx.matched_p = curr_p;
          replace_ctx.match_byte_pos = (lit_utf8_size_t) (curr_p - replace_ctx.string_p);

          ecma_builtin_replace_substitute (&replace_ctx);
        }

        if (!replace_all
            || last_match_end_p == input_end_p)
        {
          break;
        }

        if (search_size != 0)
        {
          curr_p = last_match_end_p;
          continue;
        }
      }

      pos++;
      lit_utf8_incr (&curr_p);
    }

    ecma_stringbuilder_append_raw (&replace_ctx.builder,
                                    last_match_end_p,
                                    (lit_utf8_size_t) (input_end_p - last_match_end_p));
    result_string_p = ecma_stringbuilder_finalize (&replace_ctx.builder);

  }

  if (result_string_p == NULL)
  {
    ecma_ref_ecma_string (input_str_p);
    result_string_p = input_str_p;
  }

  result = ecma_make_string_value (result_string_p);

cleanup_replace:
  if (input_flags & ECMA_STRING_FLAG_MUST_BE_FREED)
  {

Review comment (bug):
`pos` also needs to be incremented by the length of the search string, otherwise following matches will use an incorrect position. This should fix the last failing test.

The `ecma_string_get_chars` call on line 557 could be updated to retrieve the length.

Code after:
          {
            ecma_stringbuilder_destroy (&replace_ctx.builder);
            result = ECMA_VALUE_ERROR;
            goto cleanup_replace;
          }

          ecma_stringbuilder_append (&replace_ctx.builder, result_str_p);
          ecma_deref_ecma_string (result_str_p);
        }
        else
        {
          replace_ctx.matched_p = curr_p;
          replace_ctx.match_byte_pos = (lit_utf8_size_t) (curr_p - replace_ctx.string_p);

          ecma_builtin_replace_substitute (&replace_ctx);
        }

        if (!replace_all
            || last_match_end_p == input_end_p)
        {
          break;
        }

        if (search_size != 0)
        {
          curr_p = last_match_end_p;
          pos += search_length;
          continue;
        }
      }

      pos++;
      lit_utf8_incr (&curr_p);
    }

    ecma_stringbuilder_append_raw (&replace_ctx.builder,
                                    last_match_end_p,
                                    (lit_utf8_size_t) (input_end_p - last_match_end_p));
    result_string_p = ecma_stringbuilder_finalize (&replace_ctx.builder);

  }

  if (result_string_p == NULL)
  {
    ecma_ref_ecma_string (input_str_p);
    result_string_p = input_str_p;
  }

  result = ecma_make_string_value (result_string_p);

cleanup_replace:
Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/base/ecma-helpers-string.c (C)

Code before:
  const lit_utf8_byte_t *current_p = *utf8_str_p;

  while (current_p < nonws_start_p)
  {
    lit_utf8_size_t read_size = lit_read_code_unit_from_utf8 (current_p, &ch);
    if (!lit_char_is_white_space (ch))
    {
      nonws_start_p = current_p;
      break;
    }

    current_p += read_size;
  }

  *utf8_str_size = (lit_utf8_size_t) (*utf8_str_p + *utf8_str_size - nonws_start_p);
  *utf8_str_p = nonws_start_p;
} /* ecma_string_trim_front */

/**
 * Helper function for trimming.
 *
 * Used by:
 *        - ecma_string_trim_helper
 */
void ecma_string_trim_back (const lit_utf8_byte_t **utf8_str_p, /**< [in, out] current string position */
                             lit_utf8_size_t *utf8_str_size)  /**< [in, out] size of the given string */
{
  ecma_char_t ch;
  const lit_utf8_byte_t *nonws_end_p = *utf8_str_p;
  const lit_utf8_byte_t *current_p = *utf8_str_p + *utf8_str_size;

  while (current_p > nonws_end_p)
  {
    lit_utf8_size_t read_size = lit_read_prev_code_unit_from_utf8 (current_p, &ch);
    if (!lit_char_is_white_space (ch))
    {
      break;
    }
    current_p -= read_size;
  }

  *utf8_str_size = *utf8_str_size - (lit_utf8_size_t) ((*utf8_str_p + *utf8_str_size) - current_p);
} /* ecma_string_trim_back */

/**
 * Helper function for trimming.
 *
 * Used by:
 *        - ecma_string_trim
 *        - ecma_utf8_string_to_number
 *        - ecma_builtin_global_object_parse_int

Review comment (suggestion):
I suggest to change the prototype of the new functions to be
```c
const lit_utf8_byte_t *
ecma_string_trim_front (const lit_utf8_byte_t *start_p, const lit_utf8_byte_t *end_p);
const lit_utf8_byte_t *
ecma_string_trim_back (const lit_utf8_byte_t *start_p, const lit_utf8_byte_t *end_p);
```
where the return value is the new start/end position respectively.

Code after:
ecma_string_trim_front (const lit_utf8_byte_t *start_p, /**< current string's start position */
                        const lit_utf8_byte_t *end_p)  /**< current string's end position */
{
  ecma_char_t ch;

  while (start_p < end_p)
  {
    lit_utf8_size_t read_size = lit_read_code_unit_from_utf8 (start_p, &ch);

    if (!lit_char_is_white_space (ch))
    {
      break;
    }

    start_p += read_size;
  }

  return start_p;
} /* ecma_string_trim_front */

/**
 * Helper function for trimming.
 *
 * Used by:
 *        - ecma_string_trim_helper
 *
 * @return position of the last non whitespace character.
 */
const lit_utf8_byte_t *
ecma_string_trim_back (const lit_utf8_byte_t *start_p, /**< current string's start position */
                       const lit_utf8_byte_t *end_p)  /**< current string's end position */
{
  ecma_char_t ch;

  while (end_p > start_p)
  {
    lit_utf8_size_t read_size = lit_read_prev_code_unit_from_utf8 (end_p, &ch);

    if (!lit_char_is_white_space (ch))
    {
      break;
    }

    end_p -= read_size;
  }

  return end_p;
} /* ecma_string_trim_back */

/**
 * Helper function for trimming.
Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/operations/ecma-symbol-object.c (C)

Code before:

/** \addtogroup ecma ECMA
 * @{
 *
 * \addtogroup ecmasymbolobject ECMA Symbol object related routines
 * @{
 */

/**
 * Symbol creation operation.
 *
 * See also: ECMA-262 v6, 6.1.5.1
 *
 * @return ecma value
 *         Returned value must be freed with ecma_free_value
 */
ecma_value_t
ecma_op_create_symbol (const ecma_value_t *arguments_list_p, /**< list of arguments */
                       uint32_t arguments_list_len) /**< length of the arguments' list */
{
  JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);

  ecma_value_t string_desc;

  /* 1-3. */
  if (arguments_list_len == 0 || (arguments_list_len > 0 && ecma_is_value_undefined (arguments_list_p[0])))
  {
    string_desc = ECMA_VALUE_UNDEFINED;
  }
  else
  {
    ecma_string_t *str_p = ecma_op_to_string (arguments_list_p[0]);

    /* 4. */
    if (JERRY_UNLIKELY (str_p == NULL))
    {
      return ECMA_VALUE_ERROR;
    }

    string_desc = ecma_make_string_value (str_p);
  }

  /* 5. */
  return ecma_make_symbol_value (ecma_new_symbol_from_descriptor_string (string_desc));
} /* ecma_op_create_symbol */

/**
 * Symbol object creation operation.
 *
 * See also: ECMA-262 v6, 19.4.1
 *

Review comment (suggestion):
`arguments_list_len == 0` checks whether the number is 0, so no need `arguments_list_len > 0` afterwards

Code after:

/** \addtogroup ecma ECMA
 * @{
 *
 * \addtogroup ecmasymbolobject ECMA Symbol object related routines
 * @{
 */

/**
 * Symbol creation operation.
 *
 * See also: ECMA-262 v6, 6.1.5.1
 *
 * @return ecma value
 *         Returned value must be freed with ecma_free_value
 */
ecma_value_t
ecma_op_create_symbol (const ecma_value_t *arguments_list_p, /**< list of arguments */
                       uint32_t arguments_list_len) /**< length of the arguments' list */
{
  JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);

  ecma_value_t string_desc;

  /* 1-3. */
  if (arguments_list_len == 0 || ecma_is_value_undefined (arguments_list_p[0]))
  {
    string_desc = ECMA_VALUE_UNDEFINED;
  }
  else
  {
    ecma_string_t *str_p = ecma_op_to_string (arguments_list_p[0]);

    /* 4. */
    if (JERRY_UNLIKELY (str_p == NULL))
    {
      return ECMA_VALUE_ERROR;
    }

    string_desc = ecma_make_string_value (str_p);
  }

  /* 5. */
  return ecma_make_symbol_value (ecma_new_symbol_from_descriptor_string (string_desc));
} /* ecma_op_create_symbol */

/**
 * Symbol object creation operation.
 *
 * See also: ECMA-262 v6, 19.4.1
 *
Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/operations/ecma-objects-general.c (C)

Code before:
 * @return pointer to newly created 'Object' object
 */
ecma_object_t *
ecma_op_create_object_object_noarg (void)
{
  ecma_object_t *object_prototype_p = ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE);

  /* 3., 4., 6., 7. */
  return ecma_op_create_object_object_noarg_and_set_prototype (object_prototype_p);
} /* ecma_op_create_object_object_noarg */

/**
 * 'Object' object creation operation with one argument.
 *
 * See also: ECMA-262 v5, 15.2.2.1
 *
 * @return pointer to newly created 'Object' object
 */
ecma_value_t
ecma_op_create_object_object_arg (ecma_value_t value) /**< argument of constructor */
{
  ecma_check_value_type_is_spec_defined (value);

  if (ecma_is_value_object (value)
      || ecma_is_value_number (value)
      || ecma_is_value_prop_name (value)
      || ecma_is_value_boolean (value)
#if ENABLED (JERRY_ESNEXT)
      || ecma_is_value_bigint (value)
#endif /* ENABLED (JERRY_ESNEXT) */
     )
  {
    /* 1.b, 1.c, 1.d */
    return ecma_op_to_object (value);
  }
  else
  {
    /* 2. */
    JERRY_ASSERT (ecma_is_value_undefined (value)
                  || ecma_is_value_null (value));

    ecma_object_t *obj_p = ecma_op_create_object_object_noarg ();

    return ecma_make_object_value (obj_p);
  }
} /* ecma_op_create_object_object_arg */

/**
 * Object creation operation with no arguments.
 * It sets the given prototype to the newly created object.
 *

Review comment (refactor):
If you move this up, you don't need an extra `)` at the end (you can put it under `ecma_is_value_number`)

Code after:
 * @return pointer to newly created 'Object' object
 */
ecma_object_t *
ecma_op_create_object_object_noarg (void)
{
  ecma_object_t *object_prototype_p = ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE);

  /* 3., 4., 6., 7. */
  return ecma_op_create_object_object_noarg_and_set_prototype (object_prototype_p);
} /* ecma_op_create_object_object_noarg */

/**
 * 'Object' object creation operation with one argument.
 *
 * See also: ECMA-262 v5, 15.2.2.1
 *
 * @return pointer to newly created 'Object' object
 */
ecma_value_t
ecma_op_create_object_object_arg (ecma_value_t value) /**< argument of constructor */
{
  ecma_check_value_type_is_spec_defined (value);

  if (!ecma_is_value_undefined (value)
      && !ecma_is_value_null (value))
  {
    /* 1.b, 1.c, 1.d */
    JERRY_ASSERT (ecma_is_value_object (value)
                  || ecma_is_value_number (value)
                  || ecma_is_value_prop_name (value)
                  || ecma_is_value_boolean (value)
                  || ECMA_CHECK_BIGINT_IN_ASSERT (value));

    return ecma_op_to_object (value);
  }
  else
  {
    /* 2. */
    JERRY_ASSERT (ecma_is_value_undefined (value)
                  || ecma_is_value_null (value));

    ecma_object_t *obj_p = ecma_op_create_object_object_noarg ();

    return ecma_make_object_value (obj_p);
  }
} /* ecma_op_create_object_object_arg */

/**
 * Object creation operation with no arguments.
 * It sets the given prototype to the newly created object.
 *
Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/operations/ecma-bigint.c (C)

Code before:

  ecma_extended_primitive_t *result_p = NULL;

  if (string_p == string_end_p)
  {
    return ECMA_BIGINT_ZERO;
  }

  do
  {
    ecma_bigint_digit_t digit = radix;

    if (*string_p >= LIT_CHAR_0 && *string_p <= LIT_CHAR_9)
    {
      digit = (ecma_bigint_digit_t) (*string_p - LIT_CHAR_0);
    }
    else
    {
      lit_utf8_byte_t character = (lit_utf8_byte_t) LEXER_TO_ASCII_LOWERCASE (*string_p);

      if (character >= LIT_CHAR_LOWERCASE_A && character <= LIT_CHAR_LOWERCASE_F)
      {
        digit = (ecma_bigint_digit_t) (character - (LIT_CHAR_LOWERCASE_A - 10));
      }
    }
    if (lit_char_is_white_space (*string_p))
    {
      const lit_utf8_byte_t *possible_end = ecma_string_trim_front (string_p, string_end_p);
      if (possible_end == string_end_p)
      {
        string_p = string_end_p;
        break;
      }
    }

    if (digit >= radix)
    {
      if (result_p != NULL)
      {
        ecma_deref_bigint (result_p);
      }

      if (options & ECMA_BIGINT_PARSE_DISALLOW_SYNTAX_ERROR)
      {
        return ECMA_VALUE_FALSE;
      }
      return ecma_raise_syntax_error (ECMA_ERR_MSG ("String cannot be converted to BigInt value"));
    }

    result_p = ecma_big_uint_mul_digit (result_p, radix, digit);


Review comment (suggestion):
I would add the code here with an else:
```
else
{
  const lit_utf8_byte_t *possible_end = ecma_string_trim_front (string_p, string_end_p);
  if (possible_end == string_end_p) ...
}
```
Note: there is no need to check the next character is a white space because `ecma_string_trim_front` will do it automatically

Code after:
    string_p++;
  }

  ecma_extended_primitive_t *result_p = NULL;

  if (string_p == string_end_p)
  {
    return ECMA_BIGINT_ZERO;
  }

  do
  {
    ecma_bigint_digit_t digit = radix;

    if (*string_p >= LIT_CHAR_0 && *string_p <= LIT_CHAR_9)
    {
      digit = (ecma_bigint_digit_t) (*string_p - LIT_CHAR_0);
    }
    else
    {
      lit_utf8_byte_t character = (lit_utf8_byte_t) LEXER_TO_ASCII_LOWERCASE (*string_p);

      if (character >= LIT_CHAR_LOWERCASE_A && character <= LIT_CHAR_LOWERCASE_F)
      {
        digit = (ecma_bigint_digit_t) (character - (LIT_CHAR_LOWERCASE_A - 10));
      }
      else if (ecma_string_trim_front (string_p, string_end_p) == string_end_p)
      {
        string_p = string_end_p;
        break;
      }
    }
    if (digit >= radix)
    {
      if (result_p != NULL)
      {
        ecma_deref_bigint (result_p);
      }

      if (options & ECMA_BIGINT_PARSE_DISALLOW_SYNTAX_ERROR)
      {
        return ECMA_VALUE_FALSE;
      }
      return ecma_raise_syntax_error (ECMA_ERR_MSG ("String cannot be converted to BigInt value"));
    }

    result_p = ecma_big_uint_mul_digit (result_p, radix, digit);

    if (JERRY_UNLIKELY (result_p == NULL))
    {
      break;