mirror of
https://github.com/lua/lua
synced 2026-09-27 00:28:25 +03:00
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).
This commit is contained in:
parent
4846f7e3bb
commit
d6af81084d
5 changed files with 54 additions and 18 deletions
|
|
@ -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 <const> 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'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue