moonsharp-devs / moonsharp

An interpreter for the Lua language, written entirely in C# for the .NET, Mono, Xamarin and Unity3D platforms, including handy remote debugger facilities.

Home Page:http://www.moonsharp.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Returning null from callback invoked in CallbackFunction causes NullReferenceException

ThisIsNoZaku opened this issue · comments

In Processor_InstructionLoop.cs, if the CLR function wrapped by a CallbackFunction returns null, that null is pushed on the value stack and the processor proceeds on to call Internal_CheckForTailRequests. In Internal_CheckForTailRequests, a check of the type is attempted, causeing a NullReferenceException to be thrown.

At the very least, I believe Internal_CheckForTailRequests should do a null check and give a explanatory message. A better solution, in my opinion, is that the null should cause Nil to be pushed onto the stack instead.