Repository navigation
Honor __len in Lua 5.2 table-library operations - #362
Merged
Merged
Conversation
Collaborator
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #361.
Table-library operations currently read
ArrayLengthinstead of invoking__len. Use the existing VM length-metamethod dispatch and await asynchronous handlers.unpackandconcatevaluate it only when their upper bound is omitted or nil;insert,removeandsortuse it for their operation range.Lua 5.2 requires the element accesses themselves to remain raw. Shifting and sorting therefore use raw table keys within the logical range, rather than assuming the backing array's size or sequence length is the intended range. This also handles an empty/custom length, values beyond the logical end, and a length larger than existing storage. Invalid length results produce a Lua error.
Adds 29 regression cases: 27 fail on the original implementation and all pass with this change. Coverage includes all five functions, explicit/nil bounds, async handlers, protected errors and state reuse, raw accesses, and a hook that mutates the table. The minimal
unpackreproducer matches PUC-Rio Lua 5.2.3 byte-for-byte in two repetitions.Validation on Linux x64, SDK 10.0.401 / runtime 8.0.32:
DOTNET_GCHeapHardLimit=0x40000000 dotnet test tests/Lua.Tests/Lua.Tests.csproj -c Release --filter "TestCategory!=ExpectedFailure": 585 passed (unchanged baseline: 556 passed).dotnet build src/Lua/Lua.csproj -c Release: all four target frameworks build.dotnet csharpier check .andgit diff --check: pass.The heap limit is needed on this server for the existing large-allocation tests; without it the unmodified suite was killed by the OS. The project-defined
ExpectedFailurefilter is unchanged. No performance claim is made; direct hostLuaTableAPIs are unchanged.