Skip to content

Commit

Permalink
fix(compat): make compat.warn compatible with OpenResty's global scop…
Browse files Browse the repository at this point in the history
…e protection
  • Loading branch information
piotrp authored and Tieske committed Jan 15, 2022
1 parent 16743e9 commit ee42e92
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ deprecation policy.

see [CONTRIBUTING.md](CONTRIBUTING.md#release-instructions-for-a-new-version) for release instructions

## 1.13.0 (unreleased)
- fix: `compat.warn` raised write guard warning in OpenResty
[#414](https://github.com/lunarmodules/Penlight/pull/414)

## 1.12.0 (2022-Jan-10)
- deprecate: module `pl.text` the contents have moved to `pl.stringx` (removal later)
[#407](https://github.com/lunarmodules/Penlight/pull/407)
Expand Down
4 changes: 3 additions & 1 deletion lua/pl/compat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ end
-- @param ... any arguments
if not warn then -- luacheck: ignore
local enabled = false
function warn(arg1, ...) -- luacheck: ignore
local function warn(arg1, ...) -- luacheck: ignore
if type(arg1) == "string" and arg1:sub(1, 1) == "@" then
-- control message
if arg1 == "@on" then
Expand All @@ -245,6 +245,8 @@ if not warn then -- luacheck: ignore
io.stderr:write("\n")
end
end
-- use rawset to bypass OpenResty's protection of global scope
rawset(_G, "warn", warn)
end

return compat

0 comments on commit ee42e92

Please sign in to comment.