Repository: nodejs/node
File: src/node_env_var.cc (C++)

Code before:
    } else {
      return EnvSetter(property, desc.value(), info);
    }
  } else if (desc.has_get() || desc.has_set()) {
    // we don't accept a getter/setter in 'process.env'
    THROW_ERR_INVALID_OBJECT_DEFINE_PROPERTY(env,
                                             "'process.env' does not accept an"
                                             " accessor(getter/setter)"
                                             " descriptor");
    return Intercepted::kYes;
  } else {
    THROW_ERR_INVALID_OBJECT_DEFINE_PROPERTY(env,
                                             "'process.env' only accepts a "
                                             "configurable, writable,"
                                             " and enumerable "
                                             "data descriptor");
    return Intercepted::kYes;
  }
}

static Intercepted EnvGetterIndexed(uint32_t index,
                                    const PropertyCallbackInfo<Value>& info) {
  Environment* env = Environment::GetCurrent(info);
  Local<Name> name;
  if (!Uint32ToString(env->context(), index).ToLocal(&name)) {
    return Intercepted::kYes;
  }
  return EnvGetter(name, info);
}

static Intercepted EnvSetterIndexed(uint32_t index,
                                    Local<Value> value,
                                    const PropertyCallbackInfo<void>& info) {
  Environment* env = Environment::GetCurrent(info);
  Local<Name> name;
  if (!Uint32ToString(env->context(), index).ToLocal(&name)) {
    return Intercepted::kYes;
  }
  return EnvSetter(name, value, info);
}

static Intercepted EnvQueryIndexed(uint32_t index,
                                   const PropertyCallbackInfo<Integer>& info) {
  Environment* env = Environment::GetCurrent(info);
  Local<Name> name;
  if (!Uint32ToString(env->context(), index).ToLocal(&name)) {
    return Intercepted::kYes;
  }
  return EnvQuery(name, info);
}


Review comment (bug):
If the uint32 failed to be converted to a string, this should return a `Intercepted::kNo`, right?

```suggestion
    return Intercepted::kNo;
```

Code after:
    } else {
      return EnvSetter(property, desc.value(), info);
    }
  } else if (desc.has_get() || desc.has_set()) {
    // we don't accept a getter/setter in 'process.env'
    THROW_ERR_INVALID_OBJECT_DEFINE_PROPERTY(env,
                                             "'process.env' does not accept an"
                                             " accessor(getter/setter)"
                                             " descriptor");
    return Intercepted::kYes;
  } else {
    THROW_ERR_INVALID_OBJECT_DEFINE_PROPERTY(env,
                                             "'process.env' only accepts a "
                                             "configurable, writable,"
                                             " and enumerable "
                                             "data descriptor");
    return Intercepted::kYes;
  }
}

static Intercepted EnvGetterIndexed(uint32_t index,
                                    const PropertyCallbackInfo<Value>& info) {
  Environment* env = Environment::GetCurrent(info);
  Local<Name> name = Uint32ToString(env->context(), index);
  return EnvGetter(name, info);
}

static Intercepted EnvSetterIndexed(uint32_t index,
                                    Local<Value> value,
                                    const PropertyCallbackInfo<void>& info) {
  Environment* env = Environment::GetCurrent(info);
  Local<Name> name = Uint32ToString(env->context(), index);
  return EnvSetter(name, value, info);
}

static Intercepted EnvQueryIndexed(uint32_t index,
                                   const PropertyCallbackInfo<Integer>& info) {
  Environment* env = Environment::GetCurrent(info);
  Local<Name> name = Uint32ToString(env->context(), index);
  return EnvQuery(name, info);
}

static Intercepted EnvDeleterIndexed(
    uint32_t index, const PropertyCallbackInfo<Boolean>& info) {
  Environment* env = Environment::GetCurrent(info);
  Local<Name> name = Uint32ToString(env->context(), index);
  return EnvDeleter(name, info);
}

static Intercepted EnvDefinerIndexed(uint32_t index,
                                     const PropertyDescriptor& desc,