aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2006-08-07 16:04:06 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2006-08-07 16:04:06 -0300
commitca7e5b5cb62246653647753f5a6e7fa85e8f030d (patch)
treecbf652660c45c0bff4a5ca7d20c6cb92ccc34067
parent5019b2dd205751c6f29c4ced2b6f1e22c096fb83 (diff)
downloadlua-ca7e5b5cb62246653647753f5a6e7fa85e8f030d.tar.gz
lua-ca7e5b5cb62246653647753f5a6e7fa85e8f030d.tar.bz2
lua-ca7e5b5cb62246653647753f5a6e7fa85e8f030d.zip
wrong message error in some cases involving closures
-rw-r--r--bugs43
-rw-r--r--ldebug.c10
2 files changed, 49 insertions, 4 deletions
diff --git a/bugs b/bugs
index c0eb3271..ad6d0f07 100644
--- a/bugs
+++ b/bugs
@@ -1052,3 +1052,46 @@ patch = [[
1052]], 1052]],
1053 1053
1054} 1054}
1055
1056
1057Bug{
1058what = [[wrong message error in some cases involving closures]],
1059
1060report = [[Shmuel Zeigerman, on 07/2006]],
1061
1062since = "Lua 5.1",
1063
1064example = [[
1065local Var
1066local function main()
1067 NoSuchName (function() Var=0 end)
1068end
1069main()
1070--> lua5.1: temp:3: attempt to call upvalue 'Var' (a nil value)
1071]],
1072
1073patch = [[
1074*ldebug.c:
1075@@ -435,14 +435,16 @@
1076 break;
1077 }
1078 case OP_CLOSURE: {
1079- int nup;
1080+ int nup, j;
1081 check(b < pt->sizep);
1082 nup = pt->p[b]->nups;
1083 check(pc + nup < pt->sizecode);
1084- for (; nup>0; nup--) {
1085- OpCode op1 = GET_OPCODE(pt->code[pc+nup]);
1086+ for (j = 1; j <= nup; j++) {
1087+ OpCode op1 = GET_OPCODE(pt->code[pc + j]);
1088 check(op1 == OP_GETUPVAL || op1 == OP_MOVE);
1089 }
1090+ if (reg != NO_REG) /* tracing? */
1091+ pc += nup; /* do not 'execute' these pseudo-instructions */
1092 break;
1093 }
1094 case OP_VARARG: {
1095]],
1096
1097}
diff --git a/ldebug.c b/ldebug.c
index 66a32f37..10496741 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 2.29 2005/12/22 16:19:56 roberto Exp roberto $ 2** $Id: ldebug.c,v 2.30 2006/07/11 15:53:29 roberto Exp roberto $
3** Debug Interface 3** Debug Interface
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -435,14 +435,16 @@ static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
435 break; 435 break;
436 } 436 }
437 case OP_CLOSURE: { 437 case OP_CLOSURE: {
438 int nup; 438 int nup, j;
439 check(b < pt->sizep); 439 check(b < pt->sizep);
440 nup = pt->p[b]->nups; 440 nup = pt->p[b]->nups;
441 check(pc + nup < pt->sizecode); 441 check(pc + nup < pt->sizecode);
442 for (; nup>0; nup--) { 442 for (j = 1; j <= nup; j++) {
443 OpCode op1 = GET_OPCODE(pt->code[pc+nup]); 443 OpCode op1 = GET_OPCODE(pt->code[pc + j]);
444 check(op1 == OP_GETUPVAL || op1 == OP_MOVE); 444 check(op1 == OP_GETUPVAL || op1 == OP_MOVE);
445 } 445 }
446 if (reg != NO_REG) /* tracing? */
447 pc += nup; /* do not 'execute' these pseudo-instructions */
446 break; 448 break;
447 } 449 }
448 case OP_VARARG: { 450 case OP_VARARG: {