Browse files

Make getfenv more closely match 5.1's behavior

According to "The
default for f is 1" so when there is no argument passed, we should be
passing 1 into debug.getinfo. Without this, Lua complains about the
"attempt to perform arithmetic on local 'f' (a nil value)".  Hence f
should be initialized to 0 when no argument is passed.
  • Loading branch information...
1 parent 60996ff commit 664888dd4c780d7147868ae7e342c297960a0aa3 @norman norman committed Apr 11, 2012
Showing with 1 addition and 0 deletions.
  1. +1 −0 lua/pl/utils.lua
@@ -234,6 +234,7 @@ else
function getfenv(f)
+ local f = f or 0
f = (type(f) == 'function' and f or debug.getinfo(f + 1, 'f').func)
local name, val
local up = 0

0 comments on commit 664888d

Please sign in to comment.