Sitelet https://github.com/lua-stdlib/strict/commit/858cfe2938ca21b69255c8b784f54b0655562185
Skip to content

Commit 858cfe2

Browse files
committed
_base: use setfenv when available to enforce _ENV
* lib/std/strict/_base.lua (_ENV, getmetamethod): Fix spacing. (_ENV.setfenv): Default to host setfenv when available. * NEWS.md: Update. Signed-off-by: Gary V. Vaughan <gary@gnu.org>
1 parent b8d7e77 commit 858cfe2

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

‎NEWS.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Noteworthy changes in release ?.? (????-??-??)
44

5+
### Bug Fixes
6+
7+
- where available, use setfenv to enforce _ENV table.
58

69

710
## Noteworthy changes in release 1.2 (2017-02-04) [stable]

‎lib/std/strict/_base.lua‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
]]
1212

1313
local _ENV = {
14-
getmetatable = getmetatable,
15-
pairs = pairs,
16-
setfenv = function() end,
17-
setmetatable = setmetatable,
18-
type = type,
14+
getmetatable = getmetatable,
15+
pairs = pairs,
16+
setfenv = setfenv or function() end,
17+
setmetatable = setmetatable,
18+
type = type,
1919
}
2020
setfenv(1, _ENV)
2121

@@ -25,7 +25,7 @@ setfenv(1, _ENV)
2525
-- @string n name of metamethod to look up
2626
-- @treturn function|nil metamethod function, if callable, otherwise `nil`
2727
local function getmetamethod(x, n)
28-
local m =(getmetatable(x) or {})[n]
28+
local m = (getmetatable(x) or {})[n]
2929
if type(m) == 'function' then
3030
return m
3131
end

0 commit comments

Comments
 (0)