diff options
Diffstat (limited to 'testes')
-rw-r--r-- | testes/locals.lua | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/testes/locals.lua b/testes/locals.lua index 24681dd9..340af61c 100644 --- a/testes/locals.lua +++ b/testes/locals.lua | |||
@@ -225,21 +225,24 @@ end | |||
225 | 225 | ||
226 | 226 | ||
227 | do | 227 | do |
228 | -- to-be-closed variables must be closed in tail calls | 228 | -- calls cannot be tail in the scope of to-be-closed variables |
229 | local X, Y | 229 | local X, Y |
230 | local function foo () | 230 | local function foo () |
231 | local *toclose _ = function () Y = 10 end | 231 | local *toclose _ = function () Y = 10 end |
232 | assert(X == 20 and Y == nil) | 232 | assert(X == true and Y == nil) -- 'X' not closed yet |
233 | return 1,2,3 | 233 | return 1,2,3 |
234 | end | 234 | end |
235 | 235 | ||
236 | local function bar () | 236 | local function bar () |
237 | local *toclose _ = function () X = 20 end | 237 | local *toclose _ = function () X = false end |
238 | return foo() | 238 | X = true |
239 | do | ||
240 | return foo() -- not a tail call! | ||
241 | end | ||
239 | end | 242 | end |
240 | 243 | ||
241 | local a, b, c, d = bar() | 244 | local a, b, c, d = bar() |
242 | assert(a == 1 and b == 2 and c == 3 and X == 20 and Y == 10 and d == nil) | 245 | assert(a == 1 and b == 2 and c == 3 and X == false and Y == 10 and d == nil) |
243 | end | 246 | end |
244 | 247 | ||
245 | 248 | ||