multiple returns in function calls / table definitions
local a = { "one", "two", "three" }
local b = { unpack(a), "four" }
local c = { "four", unpack(a) }
print(#b) -- 2
print(#c) -- 4
unpack's behavior is quite unintuitive; when the output is not in the last position of a table definition, only the first element is actually included in the new table. (In fact, this not only applies to unpack, but to every function that returns multiple values – only happens most often with unpack that will people will notice, I assume.)
I think a diagnostic that reminds one of such cases would be very useful, since it's a common gotcha in lua.
string concatenation
print("foo" + "bar")
Common mistake to not use .. for string concatenation. Even though I am used to lua, it still happens to me all the time after coming back from writing in a different language. A diagnostic here would be useful. (And I am actually a bit surprised that there isn't one yet.)
multiple returns in function calls / table definitions
unpack
's behavior is quite unintuitive; when the output is not in the last position of a table definition, only the first element is actually included in the new table. (In fact, this not only applies tounpack
, but to every function that returns multiple values – only happens most often withunpack
that will people will notice, I assume.)see explainer in the docs: https://www.lua.org/manual/5.3/manual.html#3.4
I think a diagnostic that reminds one of such cases would be very useful, since it's a common gotcha in lua.
string concatenation
Common mistake to not use
..
for string concatenation. Even though I am used to lua, it still happens to me all the time after coming back from writing in a different language. A diagnostic here would be useful. (And I am actually a bit surprised that there isn't one yet.)