Closed Srlion closed 8 months ago
Thanks for the report! That's an odd one. I'll look at it when I have time 👍
So the above is not allowed, but this apparently is:
local a = {"whoa"}
local foo(a)[1] = a[1]
print("yeah this works, ", foo, ", ", a[1])
It means this:
local a = {"whoa"}
local foo
a[1] = a[1]
print("yeah this works, ", foo, ", ", a[1])
It’s because you are turning it into a statement and lua doesn’t use semicolons to end statements so it just works lol.
it expects an equal sign for local statement, but it found a parentheses so it ended the local statement and moved on, just like you can’t write (function() end) but you can write (function end)() I wrote a lua parser in lua before and it was fun, just followed: https://www.lua.org/manual/5.1/manual.html
That manual has been my guide as well, but throughout the years, people just find odd edge cases. Following the manual is one thing, being precisely equal to what the Lua code itself does is something else. I added an explicit check to disallow this case :+1:
Hey there!
just throws a warning
Unnecessary parentheses
Also prettier formats it into:
Appreciate your work, thank you for taking the time to make the linter!