Skip to content

Avoid __len calls when table.unpack has an explicit end index - #232

Open
XinyuGuan wants to merge 1 commit into
fengari-lua:masterfrom
XinyuGuan:unpack-len-default
Open

XinyuGuan wants to merge 1 commit into
fengari-lua:masterfrom
XinyuGuan:unpack-len-default

Conversation

@XinyuGuan

Copy link
Copy Markdown

Fixes #231.

table.unpack now computes the default end index only when argument 3 is absent or nil, avoiding an unexpected __len call when an explicit end index is supplied. Removes the unused luaL_opt import.

Adds regression tests for explicit, empty-range, omitted, and nil end indices. The two explicit-index cases fail before the fix and pass afterward.

Validation on Node.js v22.20.0 and Yarn 1.22.22:

  • yarn lint
  • FENGARICONF='{"LUAI_MAXSTACK":100000}' yarn test --maxWorkers=2: 40 suites passed; 593 tests passed, 21 skipped, 0 failed.
  • git diff --check

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.

table.unpack calls __len even when an explicit end index is provided

1 participant