Browse Source

fix: handle _ENV upvalue in LuaClosure

Akeit0 7 months ago
parent
commit
627b358027
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/Lua/Runtime/LuaClosure.cs

+ 5 - 0
src/Lua/Runtime/LuaClosure.cs

@@ -62,6 +62,11 @@ public sealed class LuaClosure : LuaFunction
     {
         if (description.IsLocal)
         {
+            if (description is { Index: 0, Name: "_ENV" })
+            {
+                return state.EnvUpValue;
+            }
+
             return state.GetOrAddUpValue(thread, baseIndex + description.Index);
         }