The following code block prints only the number 4, though I would expect it to print 2, 3, and 4.
do if (false) if (true) print(1) print(2) print(3) end print(4) |
Only the outer if
has this property, the inner if
's scoping is fine. Similar behavior happens without the do
block, I just included it to demonstrate the interaction of this behavior with "normal" Lua scopes.
P#129196 2023-04-30 19:56 ( Edited 2023-04-30 19:59)


In that case I'd expect this to error, rather than expand the scope to the end of the current explicit block. Especially since nesting different single-line shorthand forms seems to be just fine - I can use single-line while
, if
, and ?
together.
P#129208 2023-04-30 23:54 ( Edited 2023-04-30 23:59)
[Please log in to post a comment]