Skip to content

Commit c433b37

Browse files
committed
Stdin __gc override
1 parent a0c068b commit c433b37

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/Lua/Standard/OpenLibsExtensions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ public static void OpenIOLibrary(this LuaState state)
5252

5353
var registry = globalState.Registry;
5454
var standardIO = globalState.Platform.StandardIO;
55-
LuaValue stdin = new(new FileHandle(standardIO.Input));
55+
var stdinHandle = new FileHandle(standardIO.Input);
56+
((ILuaUserData)stdinHandle).Metatable!["__gc"] = new LuaFunction("stdin.__gc", (context, cancellationToken) => throw new LuaRuntimeException(context.State, "bad argument #1 to '__gc' (no value)"));
57+
LuaValue stdin = new(stdinHandle);
5658
LuaValue stdout = new(new FileHandle(standardIO.Output));
5759
LuaValue stderr = new(new FileHandle(standardIO.Error));
5860
registry["_IO_input"] = stdin;

0 commit comments

Comments
 (0)