aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lcode.c2
-rw-r--r--testes/calls.lua11
2 files changed, 13 insertions, 0 deletions
diff --git a/lcode.c b/lcode.c
index e7750fff..8786a721 100644
--- a/lcode.c
+++ b/lcode.c
@@ -208,6 +208,8 @@ void luaK_ret (FuncState *fs, int first, int nret) {
208 case 1: op = OP_RETURN1; break; 208 case 1: op = OP_RETURN1; break;
209 default: op = OP_RETURN; break; 209 default: op = OP_RETURN; break;
210 } 210 }
211 if (nret + 1 > MAXARG_B)
212 luaX_syntaxerror(fs->ls, "too many returns");
211 luaK_codeABC(fs, op, first, nret + 1, 0); 213 luaK_codeABC(fs, op, first, nret + 1, 0);
212} 214}
213 215
diff --git a/testes/calls.lua b/testes/calls.lua
index 9a5eed0b..409a275d 100644
--- a/testes/calls.lua
+++ b/testes/calls.lua
@@ -518,5 +518,16 @@ do -- check reuse of strings in dumps
518 end 518 end
519end 519end
520 520
521
522do -- test limit of multiple returns (254 values)
523 local code = "return 10" .. string.rep(",10", 253)
524 local res = {assert(load(code))()}
525 assert(#res == 254 and res[254] == 10)
526
527 code = code .. ",10"
528 local status, msg = load(code)
529 assert(not status and string.find(msg, "too many returns"))
530end
531
521print('OK') 532print('OK')
522return deep 533return deep