aboutsummaryrefslogtreecommitdiff
path: root/testes/goto.lua
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-01-04 13:09:47 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-01-04 13:09:47 -0200
commit4ace93ca6502dd1da38d5c06fa099d229e791ba8 (patch)
tree34f95ef56aecb56ae1db5e8b843b6e9bd2cbae51 /testes/goto.lua
parentc6f7181e910b6b2ff1346b5486a31be87b1da5af (diff)
downloadlua-4ace93ca6502dd1da38d5c06fa099d229e791ba8.tar.gz
lua-4ace93ca6502dd1da38d5c06fa099d229e791ba8.tar.bz2
lua-4ace93ca6502dd1da38d5c06fa099d229e791ba8.zip
No more to-be-closed functions
To-be-closed variables must contain objects with '__toclose' metamethods (or nil). Functions were removed for several reasons: * Functions interact badly with sandboxes. If a sandbox raises an error to interrupt a script, a to-be-closed function still can hijack control and continue running arbitrary sandboxed code. * Functions interact badly with coroutines. If a coroutine yields and is never resumed again, its to-be-closed functions will never run. To-be-closed objects, on the other hand, will still be closed, provided they have appropriate finalizers. * If you really need a function, it is easy to create a dummy object to run that function in its '__toclose' metamethod. This comit also adds closing of variables in case of panic.
Diffstat (limited to 'testes/goto.lua')
-rw-r--r--testes/goto.lua2
1 files changed, 1 insertions, 1 deletions
diff --git a/testes/goto.lua b/testes/goto.lua
index 5d863a42..f3dcfd4a 100644
--- a/testes/goto.lua
+++ b/testes/goto.lua
@@ -258,7 +258,7 @@ do
258 ::L2:: goto L3 258 ::L2:: goto L3
259 259
260 ::L1:: do 260 ::L1:: do
261 local *toclose a = function () X = true end 261 local *toclose a = setmetatable({}, {__close = function () X = true end})
262 assert(X == nil) 262 assert(X == nil)
263 if a then goto L2 end -- jumping back out of scope of 'a' 263 if a then goto L2 end -- jumping back out of scope of 'a'
264 end 264 end