Closed ixjf closed 5 years ago
@xanathar How dead is MoonSharp? I have this and one or two other changes that I'd like reviewed and possibly merged into MoonSharp.
I have 1) a fix for this, as you can see in the reference above, 2) a fix for #237 (Lua 'error' function not implementing the second parameter, 'level') - which also fixes a problem with the call stack not getting the correct source ref and hence, e.g. debug.traceback giving no position information -, and 3) an additional, bigger change to the async extensions, which is to replace the current method of using coroutines to be able to abort a running script. They are all in my fork of MoonSharp and you can see the details in the closed issues page.
Say a Lua binding in C# takes a parameter of type byte:
Since numbers in Lua are all doubles, MoonSharp attempts a conversion from double to byte. It does this by simply type casting one type to another. This doesn't work because if the value passed in Lua is out of bounds for a byte, say:
Then it will overflow and the value you get in C# will lead to unexpected behaviour. Instead, numeric conversion should fail in the case the value is out of bounds.