aboutsummaryrefslogtreecommitdiff
path: root/ltests.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-07-31 10:43:51 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-07-31 10:43:51 -0300
commitf645d3157372c73573dff221c5b26691cb0e7d56 (patch)
tree61adb1f332bbd8c0c0365b81cef8de47fa2ea06a /ltests.c
parent35b4efc270db2418bc2cac6671575a45028061c3 (diff)
downloadlua-f645d3157372c73573dff221c5b26691cb0e7d56.tar.gz
lua-f645d3157372c73573dff221c5b26691cb0e7d56.tar.bz2
lua-f645d3157372c73573dff221c5b26691cb0e7d56.zip
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.)
Diffstat (limited to 'ltests.c')
-rw-r--r--ltests.c3
1 files changed, 3 insertions, 0 deletions
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) {
1572 else if EQ("error") { 1572 else if EQ("error") {
1573 lua_error(L1); 1573 lua_error(L1);
1574 } 1574 }
1575 else if EQ("abort") {
1576 abort();
1577 }
1575 else if EQ("throw") { 1578 else if EQ("throw") {
1576#if defined(__cplusplus) 1579#if defined(__cplusplus)
1577static struct X { int x; } x; 1580static struct X { int x; } x;