aboutsummaryrefslogtreecommitdiff
path: root/testes/memerr.lua
diff options
context:
space:
mode:
authorRoberto I <roberto@inf.puc-rio.br>2025-10-30 11:07:01 -0300
committerRoberto I <roberto@inf.puc-rio.br>2025-10-30 11:07:01 -0300
commitd342328e5b24c9b3c6c5b33bfcf9f8534210b8e6 (patch)
tree033163b79dc14b69fc8d7160ae38cf3d9181533d /testes/memerr.lua
parent0149b781d438091ce086449101a916e9b4456b4e (diff)
downloadlua-d342328e5b24c9b3c6c5b33bfcf9f8534210b8e6.tar.gz
lua-d342328e5b24c9b3c6c5b33bfcf9f8534210b8e6.tar.bz2
lua-d342328e5b24c9b3c6c5b33bfcf9f8534210b8e6.zip
Vertical bar removed from syntax of vararg table
The syntax 'function foo (a, b, ...arg)' is already used by JavaScript for this same semantics, so it seems natural to use the same notation in Lua.
Diffstat (limited to 'testes/memerr.lua')
-rw-r--r--testes/memerr.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/testes/memerr.lua b/testes/memerr.lua
index 69d2ef85..2cc8f481 100644
--- a/testes/memerr.lua
+++ b/testes/memerr.lua
@@ -126,13 +126,13 @@ testamem("coroutine creation", function()
126end) 126end)
127 127
128do -- vararg tables 128do -- vararg tables
129 local function pack (... | t) return t end 129 local function pack (...t) return t end
130 local b = testamem("vararg table", function () 130 local b = testamem("vararg table", function ()
131 return pack(10, 20, 30, 40, "hello") 131 return pack(10, 20, 30, 40, "hello")
132 end) 132 end)
133 assert(b.aloc == 3) -- new table uses three memory blocks 133 assert(b.aloc == 3) -- new table uses three memory blocks
134 -- table optimized away 134 -- table optimized away
135 local function sel (n, ...|arg) return arg[n] + arg.n end 135 local function sel (n, ...arg) return arg[n] + arg.n end
136 local b = testamem("optimized vararg table", 136 local b = testamem("optimized vararg table",
137 function () return sel(2.0, 20, 30) end) 137 function () return sel(2.0, 20, 30) end)
138 assert(b.res == 32 and b.aloc == 0) -- no memory needed for this case 138 assert(b.res == 32 and b.aloc == 0) -- no memory needed for this case