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.
http://www.moonsharp.org
Other
1.41k stars 213 forks source link

'error' function not fully implemented, despite website saying it is #237

Closed ixjf closed 5 years ago

ixjf commented 5 years ago

The 'error' function in Lua is not fully implemented, despite http://www.moonsharp.org/MoonSharpStdLib.pdf saying it is. It does not handle the second parameter 'level'.

xanathar commented 5 years ago

Merged PR.

Ayplow commented 5 years ago

error still isn't fully implemented - try

print(pcall(function() error({}) end)) --> false   table: 00000000009C4AD0

https://github.com/moonsharp-devs/moonsharp/blob/7b8103d58b30c72f7122c9c20ec682f0066e635f/src/MoonSharp.Interpreter/CoreLib/BasicModule.cs#L87

causes this code to complain about the argument that was passed to error. (It's worth noting that error() is considered equivalent to error(nil))

ixjf commented 5 years ago

Indeed, the documentation for the error function is not very clear. The first parameter does not necessarily have to be a string, and it doesn't seem to be required at all either.