Explanation: Returning from a function is the last thing that should be done. It pushes the returned values back onto the stack, and jumps back to where the function was called. If there was code after the return inside the same chunk, it would never get called, and therefore it isn’t expected, and shows up as a syntax error. The code I posted has a return inside an if statement, which is in a separate chunk. The same logic applies to “break” and “continue”.