mathiasbynens / luamin

A Lua minifier written in JavaScript
https://mths.be/luamin
MIT License
217 stars 54 forks source link

Parentheses should not be removed from around calls to select() with varargs #51

Closed moody closed 4 years ago

moody commented 6 years ago

When minified, (select(n, ...)) becomes select(n,...). This causes errors in some situations, such as below:

local t = {}

local function a(...)
  print("Inserting:", (select(1, ...)))
  table.insert(t, (select(1, ...))) -- properly inserts "hello" into t

  print("Inserting:", select(1,...))
  table.insert(t, select(1,...)) -- calls insert(t, "hello", "world") which fails
end

a("hello", "world")

Output:

Inserting:  hello
Inserting:  hello   world
input:8: bad argument #2 to 'insert' (number expected, got string)