try
Updatedtry expr
try do ... endReturns early with the Err, inside a function that returns Result. At the module top level it returns the Err from the chunk, so the module yields that Err.
try do ... end is a block whose value is a Result: a plain value becomes Ok, a Result passes through as is, and a throw becomes Err carrying the traceback from the throw site. A try inside the block returns its Err from the block, not from the function around it. The value type flows, so try do return 1 end is a Result<number, ...>. The last line is the value when it is an expression, a call too: try do local n = parse() n * 2 end. The block runs in a function of its own, so ..., break, and continue inside it are errors.
The word is also free as a name. try before an operand on the same line is the operator; try(f), try = pcall, and try.field read the Luau way, so a local named try may hold pcall.
