From 127a8e80fe0d74efd26994b3877cdc77b712ea56 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 28 Feb 2025 10:10:27 -0300 Subject: '__close' gets no error object if there is no error Instead of receiving nil as a second argument, __close metamethods are called with just one argument when there are no errors. --- manual/manual.of | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'manual') diff --git a/manual/manual.of b/manual/manual.of index a55c7b49..ff4e79fe 100644 --- a/manual/manual.of +++ b/manual/manual.of @@ -1612,10 +1612,11 @@ or exiting by an error. Here, to @emph{close} a value means to call its @idx{__close} metamethod. When calling the metamethod, -the value itself is passed as the first argument -and the error object that caused the exit (if any) +the value itself is passed as the first argument. +If there was an error, +the error object that caused the exit is passed as a second argument; -if there was no error, the second argument is @nil. +otherwise, there is no second argument. The value assigned to a to-be-closed variable must have a @idx{__close} metamethod -- cgit v1.2.3-55-g6feb