# HG changeset patch # User Matthew Wild # Date 1493973883 -3600 # Node ID cf209451be5f981bc905383e19f5f318ae4087b7 # Parent 07c10f9ba77c8833aefd6b52399ff81e3e211d7c minify: Preserve _ENV, as it's lexically significant in 5.2+ diff -r 07c10f9ba77c -r cf209451be5f minify/lparser.lua --- a/minify/lparser.lua Fri May 05 09:44:05 2017 +0100 +++ b/minify/lparser.lua Fri May 05 09:44:43 2017 +0100 @@ -249,8 +249,8 @@ xref = { nameref }, -- xref, first value is declaration decl = nameref, -- location of declaration, = xref[1] } - if special then -- "self" must be not be changed - localinfo[id].isself = true + if special or name == "_ENV" then -- "self" must be not be changed + localinfo[id].preserve = true end -- this can override a local with the same name in the same scope -- but first, keep it inactive until it gets activated diff -r 07c10f9ba77c -r cf209451be5f minify/optparser.lua --- a/minify/optparser.lua Fri May 05 09:44:05 2017 +0100 +++ b/minify/optparser.lua Fri May 05 09:44:43 2017 +0100 @@ -52,7 +52,7 @@ for v in string.gmatch([[ and break do else elseif end false for function if in local nil not or repeat return then true until while -self]], "%S+") do +self _ENV]], "%S+") do SKIP_NAME[v] = true end @@ -256,10 +256,10 @@ local temp, j, gotself = {}, 1, false for i = 1, #object do local obj = object[i] - if not obj.isself then + if not obj.preserve then temp[j] = obj j = j + 1 - else + elseif obj.name == "self" then gotself = true end end