From cc9f2507c07072f04b2e7c9f60528990b6e7b723 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 3 May 2004 04:38:08 +0000 Subject: [PATCH] don't accept functions as lua return values, otherwise forgotton "()" can lead to silent errors --- stepmania/src/LuaHelpers.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/stepmania/src/LuaHelpers.cpp b/stepmania/src/LuaHelpers.cpp index a4ab76dae3..e5f1d4d8a5 100644 --- a/stepmania/src/LuaHelpers.cpp +++ b/stepmania/src/LuaHelpers.cpp @@ -149,6 +149,12 @@ try { } RAGE_ASSERT_M( lua_gettop(L) == 1, ssprintf("%i", lua_gettop(L)) ); + + /* Don't accept a function as a return value; if you really want to use a function + * as a boolean, convert it before returning. */ + if( lua_isfunction( L, -1 ) ) + throw CString( "result is a function; did you forget \"()\"?" ); + bool result = !!lua_toboolean( L, -1 ); lua_pop( L, -1 );