From bbae0ba02c9133416e429e77a75dac825ed775fd Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 13 Jul 2022 20:27:49 +0200 Subject: [PATCH] Stop using setfenv for compatibility with modern Luas. --- first/ackbuilder.lua | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 616c805d2..c1c19370a 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -345,11 +345,10 @@ local function templateexpand(list, vars) o[#o+1] = s:gsub("%%%b{}", function(expr) expr = expr:sub(3, -2) - local chunk, e = loadstring("return ("..expr..")", expr) + local chunk, e = load("return ("..expr..")", expr, nil, vars) if e then error(string.format("error evaluating expression: %s", e)) end - setfenv(chunk, vars) local value = chunk() if (value == nil) then error(string.format("template expression '%s' expands to nil (probably an undefined variable)", expr)) @@ -381,10 +380,7 @@ local function loadbuildfile(filename) local thisglobals = {} thisglobals._G = thisglobals setmetatable(thisglobals, {__index = globals}) - chunk, e = loadstring(data, "@"..filename) - if not e then - setfenv(chunk, thisglobals) - end + chunk, e = load(data, filename, nil, thisglobals) end end if e then