don't accept functions as lua return values, otherwise forgotton "()"

can lead to silent errors
This commit is contained in:
Glenn Maynard
2004-05-03 04:38:08 +00:00
parent 94b4962a88
commit cc9f2507c0
+6
View File
@@ -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 );