Repository: neovim/neovim
File: src/nvim/lua/executor.c (C)

Code before:
/// @param[in]  argvars Typval Arguments
/// @param[out] rettv The return value from the called function.
int typval_exec_lua_callable(LuaRef lua_cb, int argcount, typval_T *argvars, typval_T *rettv)
{
  lua_State *lstate = global_lstate;

  nlua_pushref(lstate, lua_cb);

  PUSH_ALL_TYPVALS(lstate, argvars, argcount, false);

  if (nlua_pcall(lstate, argcount, 1)) {
    nlua_print(lstate);
    return FCERR_OTHER;
  }

  nlua_pop_typval(lstate, rettv);

  return FCERR_NONE;
}

/// Execute Lua string
///
/// Used for nvim_exec_lua() and internally to execute a lua string.
///
/// @param[in]  str  String to execute.
/// @param[in]  chunkname Optional chunkname of executed string.
/// @param[in]  args array of ... args
/// @param[in]  mode Whether and how the the return value should be converted to Object
/// @param[in] arena  can be NULL, then nested allocations are used
/// @param[out]  err  Location where error will be saved.
///
/// @return Return value of the execution.
Object nlua_exec(const String str, const char *chunkname, const Array args, LuaRetMode mode, Arena *arena, Error *err)
{
  lua_State *const lstate = global_lstate;

  const char *name = (chunkname && chunkname[0]) ? chunkname : "<nvim>";
  if (luaL_loadbuffer(lstate, str.data, str.size, name)) {
    size_t len;
    const char *errstr = lua_tolstring(lstate, -1, &len);
    api_set_error(err, kErrorTypeValidation, "Lua: %.*s", (int)len, errstr);
    return NIL;
  }

  for (size_t i = 0; i < args.size; i++) {
    nlua_push_Object(lstate, &args.items[i], 0);
  }

  if (nlua_pcall(lstate, (int)args.size, 1)) {
    size_t len;
    const char *errstr = lua_tolstring(lstate, -1, &len);

Review comment (suggestion):
```suggestion
/// @param[in]  name Chunkname, defaults to "<nvim>".
```

Code after:
/// @param[in]  argvars Typval Arguments
/// @param[out] rettv The return value from the called function.
int typval_exec_lua_callable(LuaRef lua_cb, int argcount, typval_T *argvars, typval_T *rettv)
{
  lua_State *lstate = global_lstate;

  nlua_pushref(lstate, lua_cb);

  PUSH_ALL_TYPVALS(lstate, argvars, argcount, false);

  if (nlua_pcall(lstate, argcount, 1)) {
    nlua_print(lstate);
    return FCERR_OTHER;
  }

  nlua_pop_typval(lstate, rettv);

  return FCERR_NONE;
}

/// Execute Lua string
///
/// Used for nvim_exec_lua() and internally to execute a lua string.
///
/// @param[in]  str  String to execute.
/// @param[in]  chunkname Chunkname, defaults to "<nvim>".
/// @param[in]  args array of ... args
/// @param[in]  mode Whether and how the the return value should be converted to Object
/// @param[in] arena  can be NULL, then nested allocations are used
/// @param[out]  err  Location where error will be saved.
///
/// @return Return value of the execution.
Object nlua_exec(const String str, const char *chunkname, const Array args, LuaRetMode mode,
                 Arena *arena, Error *err)
{
  lua_State *const lstate = global_lstate;

  const char *name = (chunkname && chunkname[0]) ? chunkname : "<nvim>";
  if (luaL_loadbuffer(lstate, str.data, str.size, name)) {
    size_t len;
    const char *errstr = lua_tolstring(lstate, -1, &len);
    api_set_error(err, kErrorTypeValidation, "Lua: %.*s", (int)len, errstr);
    return NIL;
  }

  for (size_t i = 0; i < args.size; i++) {
    nlua_push_Object(lstate, &args.items[i], 0);
  }

  if (nlua_pcall(lstate, (int)args.size, 1)) {
    size_t len;