Skip to content

Honor Lua 5.3–5.5 table.insert indexed access and proxies #162

Backlog

Description

Reproduction

local t = setmetatable({'a', 'b'}, {
    __len = function() return 3 end,
    __index = function() return 'proxy' end,
    __newindex = function(s, k, v)
        print('set', k)
        rawset(s, k, v)
    end
})
table.insert(t, 2, 'new')
print(rawget(t, 4))

PUC Lua 5.3–5.5 prints set 4, set 3, and proxy on successive lines. NovaSharp prints nil. PUC Lua 5.1 and 5.2 use raw reads and writes. A two-argument append into an absent key must also use indexed assignment in Lua 5.3–5.5, including when the appended value is nil.

The versioned length conversion, length operands, positional bounds, and 64-bit keys are covered in #166. This issue tracks the separate indexed-access path and proxy validation.

Acceptance

  • Match indexed reads and writes for Lua 5.3–5.5, including absent keys, nil writes, hook call order, and table or function hooks.
  • Accept eligible proxy values that supply the length, read, and write metamethods identified by PUC Lua.
  • Preserve raw access in the Lua 5.1 and 5.2 profiles. Check related table functions that share the raw index path and record which ones need the same semantics.
  • Add paired TUnit and standalone Lua regressions across the applicable profiles, then regenerate and compare the corpus.

Lua 5.2 ltablib.c · Lua 5.3 ltablib.c

Activity

  1. changed the title [-]Match Lua 5.3–5.5 table.insert length and indexing metamethods[/-] [+]Match table.insert length and indexing metamethod semantics[/+] on Nov 24, 2026
  2. changed the title [-]Match table.insert length and indexing metamethod semantics[/-] [+]Honor Lua 5.3–5.5 table.insert indexed access and proxies[/+] on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions