Skip to content

Control/Extend.lua: table.unpack is Lua 5.2+ (undefined on 5.1), and arrayExtend is off-by-one #2

Description

@Unisay

Surfaced when the dev shell was pinned to Lua 5.1 (the pslua target); the fork previously tested on Lua 5.3, which hid this.

src/Control/Extend.luaarrayExtend used f(table.unpack(xs, i+1)):

  • table.unpack does not exist in Lua 5.1 (it is unpack in 5.1, table.unpack from 5.2) → runtime nil-call on the 5.1 target.
  • It also spread the tail as varargs and was off-by-one, whereas extend :: (Array a -> b) -> Array a -> Array b takes a single Array argument.

Fix: build the suffix sub-array with an explicit loop (no unpack) and pass it as one Array. Also the FFI value needed the paren-wrapped (function ... end) shape the pslua linker accepts.

Fixed together with the Lua-5.1 pin in the tooling-alignment PR #1 (the fix is coupled: CI cannot go green under 5.1 without it).

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