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 committed Jan 14, 2022
1 parent 16743e9 commit c887b6b
Showing 1 changed file with 3 additions and 1 deletion.
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 c887b6b

Please sign in to comment.