[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5.4 alpha: (yet more) toclose feedback
- From: v <v19930312@...>
- Date: Sun, 23 Jun 2019 23:20:48 +0300
On Sun, 2019-06-23 at 17:13 -0300, Soni "They/Them" L. wrote:
> I do wonder how <toclose> handles nil, and why it's a bug for
> <toclose>
> to close a non-closeable value.
>
> consider:
>
> local <toclose> f, err = io.open(foo)
> if not f then return nil, err end -- error: attempt to close
> non-closeable value
https://www.lua.org/work/doc/manual.html#3.3.8:
> If the value is nil, it is ignored; otherwise, if it does not have a
__close metamethod, an error is raised.
I think that in your case error is raised because `err` is marked at
toclose as well and it is a string (can't say for sure).
I have to admit that it's really inconvenient for this use case.
--
v <v19930312@gmail.com>