diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-04-07 14:59:26 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-04-07 14:59:26 -0300 |
| commit | 47cffdc723c2e0c6dfaf62b7775ca1c1d338c0a4 (patch) | |
| tree | 54d46a0530aa2ee09db66d57c66bd313a5de530e /testes | |
| parent | 36de01d9885562444ae2e2a3e0b7e01b3fb8743b (diff) | |
| download | lua-47cffdc723c2e0c6dfaf62b7775ca1c1d338c0a4.tar.gz lua-47cffdc723c2e0c6dfaf62b7775ca1c1d338c0a4.tar.bz2 lua-47cffdc723c2e0c6dfaf62b7775ca1c1d338c0a4.zip | |
Bug: tbc variables in "for" loops don't avoid tail calls
Diffstat (limited to 'testes')
| -rw-r--r-- | testes/locals.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/testes/locals.lua b/testes/locals.lua index 2c67edbd..6aad5d25 100644 --- a/testes/locals.lua +++ b/testes/locals.lua | |||
| @@ -335,6 +335,29 @@ do | |||
| 335 | end | 335 | end |
| 336 | 336 | ||
| 337 | 337 | ||
| 338 | do | ||
| 339 | -- bug in 5.4.3: previous condition (calls cannot be tail in the | ||
| 340 | -- scope of to-be-closed variables) must be valid for tbc variables | ||
| 341 | -- created by 'for' loops. | ||
| 342 | |||
| 343 | local closed = false | ||
| 344 | |||
| 345 | local function foo () | ||
| 346 | return function () return true end, 0, 0, | ||
| 347 | func2close(function () closed = true end) | ||
| 348 | end | ||
| 349 | |||
| 350 | local function tail() return closed end | ||
| 351 | |||
| 352 | local function foo1 () | ||
| 353 | for k in foo() do return tail() end | ||
| 354 | end | ||
| 355 | |||
| 356 | assert(foo1() == false) | ||
| 357 | assert(closed == true) | ||
| 358 | end | ||
| 359 | |||
| 360 | |||
| 338 | do print("testing errors in __close") | 361 | do print("testing errors in __close") |
| 339 | 362 | ||
| 340 | -- original error is in __close | 363 | -- original error is in __close |
