Calling "playdate->lua->callFunction" fails

Calling "playdate->lua->callFunction" fails in SDK 1.13.0(Mac & Playdate device).
In SDK 1.12.3, it can be called.

cfTest.zip (5.6 KB)

main.lua

function LuaFunction()
	print("=== LuaFunction")
end

CFunction()

function playdate.update()
end

main.c

int _CFunction( lua_State* L) 
{
	gpd->system->logToConsole("=== CFunction");
	const char* err = NULL;
	gpd->lua->callFunction("LuaFunction", 0, &err);
	return 0;
}

int eventHandler(PlaydateAPI* playdate, PDSystemEvent event, uint32_t arg)
{
	if ( event == kEventInitLua )
	{
		gpd = playdate;
		const char* err = NULL;
		gpd->lua->addFunction(_CFunction, "CFunction", &err);
	}
	return 0;
}

expected result:

=== CFunction
=== LuaFunction

result:

=== LuaFunction
main.lua:7: failed expression: (idx != 0 && -idx <= L->top - (ci->func + 1)) && "invalid index" at /Users/buildbot/Developer/ci-builds/dUKkfHsc/0/playdate/PlayDate/Core/minilua/lapi.c:92
stack traceback:
	[C]: in function 'CFunction'
	main.lua:7: in main chunk
1 Like

Thank you for catching this, and sorry for the trouble. I've got a fix in the queue that we'll get out ASAP.

1 Like