1print "testing string length overflow" 2 3local longs = string.rep("\0", 2^25) 4local function catter (i) 5 return assert(loadstring( 6 string.format("return function(a) return a%s end", 7 string.rep("..a", i-1))))() 8end 9rep129 = catter(129) 10local a, b = pcall(rep129, longs) 11print(b) 12assert(not a and string.find(b, "overflow")) 13print('+') 14 15 16require "checktable" 17 18--[[ lots of empty lines (to force SETLINEW) 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222--]] 223 224 225a,b = nil,nil 226while not b do 227if a then 228b = { -- lots of strings (to force JMPW and PUSHCONSTANTW) 229"n1", "n2", "n3", "n4", "n5", "n6", "n7", "n8", "n9", "n10", 230"n11", "n12", "j301", "j302", "j303", "j304", "j305", "j306", "j307", "j308", 231"j309", "a310", "n311", "n312", "n313", "n314", "n315", "n316", "n317", "n318", 232"n319", "n320", "n321", "n322", "n323", "n324", "n325", "n326", "n327", "n328", 233"a329", "n330", "n331", "n332", "n333", "n334", "n335", "n336", "n337", "n338", 234"n339", "n340", "n341", "z342", "n343", "n344", "n345", "n346", "n347", "n348", 235"n349", "n350", "n351", "n352", "r353", "n354", "n355", "n356", "n357", "n358", 236"n359", "n360", "n361", "n362", "n363", "n364", "n365", "n366", "z367", "n368", 237"n369", "n370", "n371", "n372", "n373", "n374", "n375", "a376", "n377", "n378", 238"n379", "n380", "n381", "n382", "n383", "n384", "n385", "n386", "n387", "n388", 239"n389", "n390", "n391", "n392", "n393", "n394", "n395", "n396", "n397", "n398", 240"n399", "n400", "n13", "n14", "n15", "n16", "n17", "n18", "n19", "n20", 241"n21", "n22", "n23", "a24", "n25", "n26", "n27", "n28", "n29", "j30", 242"n31", "n32", "n33", "n34", "n35", "n36", "n37", "n38", "n39", "n40", 243"n41", "n42", "n43", "n44", "n45", "n46", "n47", "n48", "n49", "n50", 244"n51", "n52", "n53", "n54", "n55", "n56", "n57", "n58", "n59", "n60", 245"n61", "n62", "n63", "n64", "n65", "a66", "z67", "n68", "n69", "n70", 246"n71", "n72", "n73", "n74", "n75", "n76", "n77", "n78", "n79", "n80", 247"n81", "n82", "n83", "n84", "n85", "n86", "n87", "n88", "n89", "n90", 248"n91", "n92", "n93", "n94", "n95", "n96", "n97", "n98", "n99", "n100", 249"n201", "n202", "n203", "n204", "n205", "n206", "n207", "n208", "n209", "n210", 250"n211", "n212", "n213", "n214", "n215", "n216", "n217", "n218", "n219", "n220", 251"n221", "n222", "n223", "n224", "n225", "n226", "n227", "n228", "n229", "n230", 252"n231", "n232", "n233", "n234", "n235", "n236", "n237", "n238", "n239", "a240", 253"a241", "a242", "a243", "a244", "a245", "a246", "a247", "a248", "a249", "n250", 254"n251", "n252", "n253", "n254", "n255", "n256", "n257", "n258", "n259", "n260", 255"n261", "n262", "n263", "n264", "n265", "n266", "n267", "n268", "n269", "n270", 256"n271", "n272", "n273", "n274", "n275", "n276", "n277", "n278", "n279", "n280", 257"n281", "n282", "n283", "n284", "n285", "n286", "n287", "n288", "n289", "n290", 258"n291", "n292", "n293", "n294", "n295", "n296", "n297", "n298", "n299" 259; x=23} 260else a = 1 end 261 262 263end 264 265assert(b.x == 23) 266print('+') 267 268stat(b) 269 270repeat 271a = { 272n1 = 1.5, n2 = 2.5, n3 = 3.5, n4 = 4.5, n5 = 5.5, n6 = 6.5, n7 = 7.5, 273n8 = 8.5, n9 = 9.5, n10 = 10.5, n11 = 11.5, n12 = 12.5, 274j301 = 301.5, j302 = 302.5, j303 = 303.5, j304 = 304.5, j305 = 305.5, 275j306 = 306.5, j307 = 307.5, j308 = 308.5, j309 = 309.5, a310 = 310.5, 276n311 = 311.5, n312 = 312.5, n313 = 313.5, n314 = 314.5, n315 = 315.5, 277n316 = 316.5, n317 = 317.5, n318 = 318.5, n319 = 319.5, n320 = 320.5, 278n321 = 321.5, n322 = 322.5, n323 = 323.5, n324 = 324.5, n325 = 325.5, 279n326 = 326.5, n327 = 327.5, n328 = 328.5, a329 = 329.5, n330 = 330.5, 280n331 = 331.5, n332 = 332.5, n333 = 333.5, n334 = 334.5, n335 = 335.5, 281n336 = 336.5, n337 = 337.5, n338 = 338.5, n339 = 339.5, n340 = 340.5, 282n341 = 341.5, z342 = 342.5, n343 = 343.5, n344 = 344.5, n345 = 345.5, 283n346 = 346.5, n347 = 347.5, n348 = 348.5, n349 = 349.5, n350 = 350.5, 284n351 = 351.5, n352 = 352.5, r353 = 353.5, n354 = 354.5, n355 = 355.5, 285n356 = 356.5, n357 = 357.5, n358 = 358.5, n359 = 359.5, n360 = 360.5, 286n361 = 361.5, n362 = 362.5, n363 = 363.5, n364 = 364.5, n365 = 365.5, 287n366 = 366.5, z367 = 367.5, n368 = 368.5, n369 = 369.5, n370 = 370.5, 288n371 = 371.5, n372 = 372.5, n373 = 373.5, n374 = 374.5, n375 = 375.5, 289a376 = 376.5, n377 = 377.5, n378 = 378.5, n379 = 379.5, n380 = 380.5, 290n381 = 381.5, n382 = 382.5, n383 = 383.5, n384 = 384.5, n385 = 385.5, 291n386 = 386.5, n387 = 387.5, n388 = 388.5, n389 = 389.5, n390 = 390.5, 292n391 = 391.5, n392 = 392.5, n393 = 393.5, n394 = 394.5, n395 = 395.5, 293n396 = 396.5, n397 = 397.5, n398 = 398.5, n399 = 399.5, n400 = 400.5, 294n13 = 13.5, n14 = 14.5, n15 = 15.5, n16 = 16.5, n17 = 17.5, 295n18 = 18.5, n19 = 19.5, n20 = 20.5, n21 = 21.5, n22 = 22.5, 296n23 = 23.5, a24 = 24.5, n25 = 25.5, n26 = 26.5, n27 = 27.5, 297n28 = 28.5, n29 = 29.5, j30 = 30.5, n31 = 31.5, n32 = 32.5, 298n33 = 33.5, n34 = 34.5, n35 = 35.5, n36 = 36.5, n37 = 37.5, 299n38 = 38.5, n39 = 39.5, n40 = 40.5, n41 = 41.5, n42 = 42.5, 300n43 = 43.5, n44 = 44.5, n45 = 45.5, n46 = 46.5, n47 = 47.5, 301n48 = 48.5, n49 = 49.5, n50 = 50.5, n51 = 51.5, n52 = 52.5, 302n53 = 53.5, n54 = 54.5, n55 = 55.5, n56 = 56.5, n57 = 57.5, 303n58 = 58.5, n59 = 59.5, n60 = 60.5, n61 = 61.5, n62 = 62.5, 304n63 = 63.5, n64 = 64.5, n65 = 65.5, a66 = 66.5, z67 = 67.5, 305n68 = 68.5, n69 = 69.5, n70 = 70.5, n71 = 71.5, n72 = 72.5, 306n73 = 73.5, n74 = 74.5, n75 = 75.5, n76 = 76.5, n77 = 77.5, 307n78 = 78.5, n79 = 79.5, n80 = 80.5, n81 = 81.5, n82 = 82.5, 308n83 = 83.5, n84 = 84.5, n85 = 85.5, n86 = 86.5, n87 = 87.5, 309n88 = 88.5, n89 = 89.5, n90 = 90.5, n91 = 91.5, n92 = 92.5, 310n93 = 93.5, n94 = 94.5, n95 = 95.5, n96 = 96.5, n97 = 97.5, 311n98 = 98.5, n99 = 99.5, n100 = 100.5, n201 = 201.5, n202 = 202.5, 312n203 = 203.5, n204 = 204.5, n205 = 205.5, n206 = 206.5, n207 = 207.5, 313n208 = 208.5, n209 = 209.5, n210 = 210.5, n211 = 211.5, n212 = 212.5, 314n213 = 213.5, n214 = 214.5, n215 = 215.5, n216 = 216.5, n217 = 217.5, 315n218 = 218.5, n219 = 219.5, n220 = 220.5, n221 = 221.5, n222 = 222.5, 316n223 = 223.5, n224 = 224.5, n225 = 225.5, n226 = 226.5, n227 = 227.5, 317n228 = 228.5, n229 = 229.5, n230 = 230.5, n231 = 231.5, n232 = 232.5, 318n233 = 233.5, n234 = 234.5, n235 = 235.5, n236 = 236.5, n237 = 237.5, 319n238 = 238.5, n239 = 239.5, a240 = 240.5, a241 = 241.5, a242 = 242.5, 320a243 = 243.5, a244 = 244.5, a245 = 245.5, a246 = 246.5, a247 = 247.5, 321a248 = 248.5, a249 = 249.5, n250 = 250.5, n251 = 251.5, n252 = 252.5, 322n253 = 253.5, n254 = 254.5, n255 = 255.5, n256 = 256.5, n257 = 257.5, 323n258 = 258.5, n259 = 259.5, n260 = 260.5, n261 = 261.5, n262 = 262.5, 324n263 = 263.5, n264 = 264.5, n265 = 265.5, n266 = 266.5, n267 = 267.5, 325n268 = 268.5, n269 = 269.5, n270 = 270.5, n271 = 271.5, n272 = 272.5, 326n273 = 273.5, n274 = 274.5, n275 = 275.5, n276 = 276.5, n277 = 277.5, 327n278 = 278.5, n279 = 279.5, n280 = 280.5, n281 = 281.5, n282 = 282.5, 328n283 = 283.5, n284 = 284.5, n285 = 285.5, n286 = 286.5, n287 = 287.5, 329n288 = 288.5, n289 = 289.5, n290 = 290.5, n291 = 291.5, n292 = 292.5, 330n293 = 293.5, n294 = 294.5, n295 = 295.5, n296 = 296.5, n297 = 297.5, 331n298 = 298.5, n299 = 299.5, j300 = 300} or 1 332until 1 333 334assert(a.n299 == 299.5) 335xxx = 1 336assert(xxx == 1) 337 338stat(a) 339 340function a:findfield (f) 341 local i,v = next(self, nil) 342 while i ~= f do 343 if not i then return end 344 i,v = next(self, i) 345 end 346 return v 347end 348 349local ii = 0 350i = 1 351while b[i] do 352 local r = a:findfield(b[i]); 353 assert(a[b[i]] == r) 354 ii = math.max(ii,i) 355 i = i+1 356end 357 358assert(ii == 299) 359 360function xxxx (x) coroutine.yield('b'); return ii+x end 361 362assert(xxxx(10) == 309) 363 364a = nil 365b = nil 366a1 = nil 367 368print("tables with table indices:") 369i = 1; a={} 370while i <= 1023 do a[{}] = i; i=i+1 end 371stat(a) 372a = nil 373 374print("tables with function indices:") 375a={} 376for i=1,511 do local x; a[function () return x end] = i end 377stat(a) 378a = nil 379 380print'OK' 381 382return 'a' 383