Reject unknown collectgarbage options#265
Merged
akeit0 merged 1 commit intonuskey8:mainfrom Mar 26, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the Lua standard library surface to better match Lua’s error behavior by rejecting unknown collectgarbage option strings and adding a __gc metamethod entry for file handles.
Changes:
- Add validation for
collectgarbage(option)to throw on unexpected option strings. - Register a
__gcmetamethod onFileHandlemetatables and implement a stub handler that errors when invoked without arguments.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/Lua/Standard/BasicLibrary.cs |
Validates collectgarbage option strings against a known set and throws on invalid options. |
src/Lua/Standard/FileHandle.cs |
Adds __gc to the file handle metatable and introduces a GcFunction implementation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7624814 to
85ec681
Compare
Closed
akeit0
requested changes
Mar 20, 2026
c433b37 to
09d125d
Compare
Contributor
Author
akeit0
requested changes
Mar 20, 2026
Collaborator
|
Revert or reopen with improving |
09d125d to
7979dce
Compare
akeit0
approved these changes
Mar 26, 2026
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.
Simple fix for failing
Test_Lua("tests-lua/errors.lua"). This is not a complete implementation of Lua GC and, similar to existing behaviour, largely ignores the GC option. However, it now throws for unexpected option strings.