From f645d3157372c73573dff221c5b26691cb0e7d56 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 31 Jul 2019 10:43:51 -0300 Subject: To-be-closed variables must be closed on initialization When initializing a to-be-closed variable, check whether it has a '__close' metamethod (or is a false value) and raise an error if if it hasn't. This produces more accurate error messages. (The check before closing still need to be done: in the C API, the value is not constant; and the object may lose its '__close' metamethod during the block.) --- ltests.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'ltests.c') diff --git a/ltests.c b/ltests.c index 09876ee7..21273ea9 100644 --- a/ltests.c +++ b/ltests.c @@ -1572,6 +1572,9 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) { else if EQ("error") { lua_error(L1); } + else if EQ("abort") { + abort(); + } else if EQ("throw") { #if defined(__cplusplus) static struct X { int x; } x; -- cgit v1.2.3-55-g6feb