diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-17 14:26:56 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-17 14:26:56 -0300 |
commit | d6af81084df569bc8e3bd0949ad6fc0b40c8468d (patch) | |
tree | 103b92a3fd9b1164763500054f7979f51f9aa4b4 /testes | |
parent | 4846f7e3bb1397142ab0de808ae59c08db9832a6 (diff) | |
download | lua-d6af81084df569bc8e3bd0949ad6fc0b40c8468d.tar.gz lua-d6af81084df569bc8e3bd0949ad6fc0b40c8468d.tar.bz2 lua-d6af81084df569bc8e3bd0949ad6fc0b40c8468d.zip |
New kind of expression VKSTR
String literal expressions have their own kind VKSTR, instead of the
generic VK. This allows strings to "cross" functions without entering
their constant tables (e.g., if they are used only by some nested
function).
Diffstat (limited to 'testes')
-rw-r--r-- | testes/code.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/testes/code.lua b/testes/code.lua index b2702c61..b5091458 100644 --- a/testes/code.lua +++ b/testes/code.lua | |||
@@ -409,5 +409,22 @@ checkequal(function () return 6 and true or nil end, | |||
409 | function () return k6 and kTrue or kNil end) | 409 | function () return k6 and kTrue or kNil end) |
410 | 410 | ||
411 | 411 | ||
412 | do -- string constants | ||
413 | local function f1 () | ||
414 | local <const> k = "00000000000000000000000000000000000000000000000000" | ||
415 | return function () | ||
416 | return function () return k end | ||
417 | end | ||
418 | end | ||
419 | |||
420 | local f2 = f1() | ||
421 | local f3 = f2() | ||
422 | assert(f3() == string.rep("0", 50)) | ||
423 | checkK(f3, f3()) | ||
424 | -- string is not needed by other functions | ||
425 | assert(T.listk(f1)[1] == nil) | ||
426 | assert(T.listk(f2)[1] == nil) | ||
427 | end | ||
428 | |||
412 | print 'OK' | 429 | print 'OK' |
413 | 430 | ||