Thanks for the detailed explanation! Did I miss this description in my read of the reference manual (I did skip the grammar)?
explains that "Lua handles a chunk as the body of an anonymous function with a variable number of arguments (see §3.4.11). As such, chunks can define local variables, receive arguments, and return values."
Once you understand from that passage that a chunk is just an ordinary anonymous function, the rest of what I described logically follows from the normal behavior of functions.