aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2007-05-16 12:39:08 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2007-05-16 12:39:08 -0300
commit6c0a9a272e3007ffd3a0da82f74525ee756e5f9c (patch)
tree01ebe421b06aad39a56e6e77ef61707d87528881
parent01fa1bc1146f74ba4a9fc7a5dd4c3109d971e257 (diff)
downloadlua-6c0a9a272e3007ffd3a0da82f74525ee756e5f9c.tar.gz
lua-6c0a9a272e3007ffd3a0da82f74525ee756e5f9c.tar.bz2
lua-6c0a9a272e3007ffd3a0da82f74525ee756e5f9c.zip
assignment of nil to parameter may be optimized away
__concat metamethod converts numbers to strings loadlib.c should not access Lua internals code generated for "-nil", "-true", and "-false" is wrong Count hook may be called without being set
-rw-r--r--bugs150
1 files changed, 145 insertions, 5 deletions
diff --git a/bugs b/bugs
index 34c72255..11d57c02 100644
--- a/bugs
+++ b/bugs
@@ -1294,10 +1294,150 @@ patch = [[
1294} 1294}
1295 1295
1296Bug{ 1296Bug{
1297what = [[ ]], 1297what = [[assignment of nil to parameter may be optimized away]],
1298report = [[ ]], 1298report = [[Thomas Lauer, on 03/2007]],
1299since = [[ ]], 1299since = [[5.1]],
1300example = [[ ]], 1300example = [[
1301patch = [[ ]], 1301function f (a)
1302 a=nil
1303 return a
1304end
1305
1306print(f("test"))
1307]],
1308patch = [[
1309*lcode.c:
1310@@ -35,16 +35,20 @@
1311 void luaK_nil (FuncState *fs, int from, int n) {
1312 Instruction *previous;
1313 if (fs->pc > fs->lasttarget) { /* no jumps to current position? */
1314- if (fs->pc == 0) /* function start? */
1315- return; /* positions are already clean */
1316- previous = &fs->f->code[fs->pc-1];
1317- if (GET_OPCODE(*previous) == OP_LOADNIL) {
1318- int pfrom = GETARG_A(*previous);
1319- int pto = GETARG_B(*previous);
1320- if (pfrom <= from && from <= pto+1) { /* can connect both? */
1321- if (from+n-1 > pto)
1322- SETARG_B(*previous, from+n-1);
1323- return;
1324+ if (fs->pc == 0) { /* function start? */
1325+ if (from >= fs->nactvar)
1326+ return; /* positions are already clean */
1327+ }
1328+ else {
1329+ previous = &fs->f->code[fs->pc-1];
1330+ if (GET_OPCODE(*previous) == OP_LOADNIL) {
1331+ int pfrom = GETARG_A(*previous);
1332+ int pto = GETARG_B(*previous);
1333+ if (pfrom <= from && from <= pto+1) { /* can connect both? */
1334+ if (from+n-1 > pto)
1335+ SETARG_B(*previous, from+n-1);
1336+ return;
1337+ }
1338 }
1339 }
1340 }
1341]],
1342}
1343
1344
1345Bug{
1346what = [[__concat metamethod converts numbers to strings]],
1347report = [[Paul Winwood, on 12/2006]],
1348since = [[5.0]],
1349example = [[
1350a = {}
1351setmetatable(a, {__concat = function (a,b) print(type(a), type(b)) end})
1352a = 4 .. a
1353]],
1354patch = [[
1355*lvm.c:
1356@@ -281,10 +281,12 @@
1357 do {
1358 StkId top = L->base + last + 1;
1359 int n = 2; /* number of elements handled in this pass (at least 2) */
1360- if (!tostring(L, top-2) || !tostring(L, top-1)) {
1361+ if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) {
1362 if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT))
1363 luaG_concaterror(L, top-2, top-1);
1364- } else if (tsvalue(top-1)->len > 0) { /* if len=0, do nothing */
1365+ } else if (tsvalue(top-1)->len == 0) /* second op is empty? */
1366+ (void)tostring(L, top - 2); /* result is first op (as string) */
1367+ else {
1368 /* at least two string values; get as many as possible */
1369 size_t tl = tsvalue(top-1)->len;
1370 char *buffer;
1371]],
1302} 1372}
1303 1373
1374
1375Bug{
1376what = [[As a library, loadlib.c should not access Lua internals
1377(via lobject.h)]],
1378report = [[Jérôme Vuarand, on 03/2007]],
1379since = [[5.0 (at least)]],
1380example = [[the bug has no effect on external behavior]],
1381patch = [[remove the '#include "lobject.h" and use
1382'lua_pushfstring' instead of 'luaO_pushfstring']],
1383}
1384
1385Bug{
1386what = [[Lua may close standard files,
1387which then may be used by C]],
1388report = [[David Manura/Ross Berteig, on 04/2007]],
1389since = [[ ]],
1390example = [[
1391io.close(io.stderr)
1392-- in some systems, following attempts to write to 'stderr' may crash
1393a = a + 1
1394]],
1395patch = [[
1396]],
1397}
1398
1399Bug{
1400what = [[code generated for "-nil", "-true", and "-false" is wrong]],
1401report = [[David Manura/Rici Lake, on 04/2007]],
1402since = [[5.1]],
1403example = [[print(-nil)]],
1404patch = [[
1405lcode.c:
1406@@ -699,7 +699,7 @@
1407 e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
1408 switch (op) {
1409 case OPR_MINUS: {
1410- if (e->k == VK)
1411+ if (!isnumeral(e))
1412 luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */
1413 codearith(fs, OP_UNM, e, &e2);
1414 break;
1415]],
1416}
1417
1418Bug{
1419what = [[Count hook may be called without being set.]],
1420report = [[Mike Pall, on May 2007]],
1421since = [[?]],
1422example = [[ ]],
1423patch = [[
1424lvm.c:
1425@@ -61,7 +61,7 @@
1426 lu_byte mask = L->hookmask;
1427 const Instruction *oldpc = L->savedpc;
1428 L->savedpc = pc;
1429- if (mask > LUA_MASKLINE) { /* instruction-hook set? */
1430+ if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) {
1431 if (L->hookcount == 0) {
1432 resethookcount(L);
1433 luaD_callhook(L, LUA_HOOKCOUNT, -1);
1434]],
1435}
1436
1437Bug{
1438what = [[ ]],
1439report = [[ , on ]],
1440since = [[i ]],
1441example = [[ ]],
1442patch = [[ ]],
1443}