From d6af81084df569bc8e3bd0949ad6fc0b40c8468d Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 17 Jul 2019 14:26:56 -0300 Subject: 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). --- testes/code.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'testes') 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, function () return k6 and kTrue or kNil end) +do -- string constants + local function f1 () + local k = "00000000000000000000000000000000000000000000000000" + return function () + return function () return k end + end + end + + local f2 = f1() + local f3 = f2() + assert(f3() == string.rep("0", 50)) + checkK(f3, f3()) + -- string is not needed by other functions + assert(T.listk(f1)[1] == nil) + assert(T.listk(f2)[1] == nil) +end + print 'OK' -- cgit v1.2.3-55-g6feb