Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meta: newproxy can accept a userdata value #1959

Merged
merged 1 commit into from Mar 2, 2023
Merged

Conversation

Bilal2453
Copy link
Contributor

In the Lua 5.1 source code (Lua 5.1.5 lbaselib.c#432-440):

  else {
    int validproxy = 0;  /* to check if weaktable[metatable(u)] == true */
    if (lua_getmetatable(L, 1)) {
      lua_rawget(L, lua_upvalueindex(1));
      validproxy = lua_toboolean(L, -1);
      lua_pop(L, 1);  /* remove value */
    }
    luaL_argcheck(L, validproxy, 1, "boolean or proxy expected");
    lua_getmetatable(L, 1);  /* metatable is valid; get it */
  }

So newproxy can accept a userdata created previously with newproxy(true):
image

@sumneko sumneko merged commit a79d7c6 into LuaLS:master Mar 2, 2023
@sumneko
Copy link
Collaborator

sumneko commented Mar 2, 2023

Thank you!

@Bilal2453 Bilal2453 deleted the patch-2 branch March 7, 2023 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants