From 594d7266af6c0a899e5218df444178c16327563e Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 8 Dec 2014 13:26:55 -0200 Subject: [PATCH] 'assert' checks that it has (at least) one parameter + 'assert' ensures it passes only one value to 'error' --- lbaselib.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lbaselib.c b/lbaselib.c index 5c73e4f8..902143ea 100644 --- a/lbaselib.c +++ b/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.306 2014/11/02 19:19:04 roberto Exp roberto $ +** $Id: lbaselib.c,v 1.307 2014/11/10 14:25:52 roberto Exp roberto $ ** Basic library ** See Copyright Notice in lua.h */ @@ -388,9 +388,10 @@ static int luaB_assert (lua_State *L) { if (lua_toboolean(L, 1)) /* condition is true? */ return lua_gettop(L); /* return all arguments */ else { /* error */ - if (lua_isnone(L, 2)) /* no error message? */ - lua_pushliteral(L, "assertion failed!"); /* use standard message */ - lua_remove(L, 1); /* remove the condition (if there is one...) */ + luaL_checkany(L, 1); /* there must be a condition */ + lua_remove(L, 1); /* remove it */ + lua_pushliteral(L, "assertion failed!"); /* default message */ + lua_settop(L, 1); /* leave only message (default if no other one) */ return luaB_error(L); /* call 'error' */ } }