Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/operations/ecma-proxy-object.c (C)

Code before:
  bool target_is_configurable = false;

  if (target_has_desc)
  {
    target_is_configurable = ((target_desc.flags & ECMA_PROP_IS_CONFIGURABLE) != 0);
    ecma_free_property_descriptor (&target_desc);
  }

  /* 21. */
  if (!is_valid)
  {
    ecma_free_property_descriptor (prop_desc_p);
    return ecma_raise_type_error (ECMA_ERR_MSG ("The two descriptors are not compatible."));
  }

  /* 22. */
  else if (!(prop_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE))
  {
    if (!target_has_desc || target_is_configurable)
    {
      ecma_free_property_descriptor (prop_desc_p);
      return ecma_raise_type_error (ECMA_ERR_MSG ("Not compatible."));
    }
    /* ES11: 9.5.5.17.b */
    if (!(prop_desc_p->flags & ECMA_PROP_IS_WRITABLE)
        && (prop_desc_p->flags & ECMA_PROP_IS_WRITABLE_DEFINED)
        && ((target_desc.flags & ECMA_PROP_IS_WRITABLE)))
    {
      return ecma_raise_type_error (ECMA_ERR_MSG ("Not compatible."));
    }
  }
  return ECMA_VALUE_TRUE;
} /* ecma_proxy_object_get_own_property_descriptor */

/**
 * The Proxy object [[DefineOwnProperty]] internal routine
 *
 * See also:
 *          ECMAScript v6, 9.5.6
 *
 * Note: Returned value is always a simple value so freeing it is unnecessary.
 *
 * @return ECMA_VALUE_ERROR - if the operation fails
 *         ECMA_VALUE_{TRUE_FALSE} - depends on whether the property can be defined for the given object
 */
ecma_value_t
ecma_proxy_object_define_own_property (ecma_object_t *obj_p, /**< proxy object */
                                       ecma_string_t *prop_name_p, /**< property name */
                                       const ecma_property_descriptor_t *prop_desc_p) /**< property descriptor */
{
  JERRY_ASSERT (ECMA_OBJECT_IS_PROXY (obj_p));

Review comment (suggestion):
`(prop_desc_p->flags & (ECMA_PROP_IS_WRITABLE_DEFINED | ECMA_PROP_IS_WRITABLE)) == ECMA_PROP_IS_WRITABLE_DEFINED`

Code after:
  bool target_is_writable = (target_desc.flags & ECMA_PROP_IS_WRITABLE) ;
  bool target_is_configurable = false;

  if (target_has_desc)
  {
    target_is_configurable = ((target_desc.flags & ECMA_PROP_IS_CONFIGURABLE) != 0);
    ecma_free_property_descriptor (&target_desc);
  }

  /* 21. */
  if (!is_valid)
  {
    ecma_free_property_descriptor (prop_desc_p);
    return ecma_raise_type_error (ECMA_ERR_MSG ("The two descriptors are not compatible."));
  }

  /* 22. */
  else if (!(prop_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE))
  {
    if (!target_has_desc || target_is_configurable)
    {
      ecma_free_property_descriptor (prop_desc_p);
      return ecma_raise_type_error (ECMA_ERR_MSG ("Not compatible."));
    }

    /* ES11: 17.b */
    if ((prop_desc_p->flags & (ECMA_PROP_IS_WRITABLE_DEFINED | ECMA_PROP_IS_WRITABLE)) == ECMA_PROP_IS_WRITABLE_DEFINED
        && target_is_writable)
    {
      ecma_free_property_descriptor (prop_desc_p);
      return ecma_raise_type_error (ECMA_ERR_MSG ("Not compatible."));
    }
  }
  return ECMA_VALUE_TRUE;
} /* ecma_proxy_object_get_own_property_descriptor */

/**
 * The Proxy object [[DefineOwnProperty]] internal routine
 *
 * See also:
 *          ECMAScript v6, 9.5.6
 *
 * Note: Returned value is always a simple value so freeing it is unnecessary.
 *
 * @return ECMA_VALUE_ERROR - if the operation fails
 *         ECMA_VALUE_{TRUE_FALSE} - depends on whether the property can be defined for the given object
 */
ecma_value_t
ecma_proxy_object_define_own_property (ecma_object_t *obj_p, /**< proxy object */
                                       ecma_string_t *prop_name_p, /**< property name */
                                       const ecma_property_descriptor_t *prop_desc_p) /**< property descriptor */