lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, 2021-08-03 at 22:55 -0700, Fermi Paradox wrote:
> Hello,

Hi,

>  I am not sure if it's a bug or not so I tried it on other platforms as
> well and it seems like this is a possible bug.

As Xmilia already pointed out, code is not parsed in comments. And it
can't be, because thinks like --[[ [[ ]] is a legal comment, but [[ is
not legal code (without the closing brackets). So this could just not
work, which means the parser has no idea what the 'outer brackets' are.

Next to using --[=[ for your comments, there is another fix for this:
introduce a space between the brackets in the table access:

local a = { 2, 3, 4 }
local b = { 1, 2, 3 }
--[[ This is legal code
print(a[b[1] ])
--]]

Furthermore, as you can see, I've added -- to the closing pair of
brackets of the comment. Why? If you do it like this, then you can
uncomment the entire block by just putting another hyphen to the
comment opening, like this:

local a = { 2, 3, 4 }
local b = { 1, 2, 3 }
---[[ This is legal code, the next statement is evaluated
print(a[b[1] ])
--]]

Apart from this, a friendly advice: When talking about code, paste the
code as text. Don't use pictures to show code, some people will feel
less likely to help you if you do this.

Kind regards,
Patrick