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.4k stars 213 forks source link

Empty tuples are incorrectly treated as nil #287

Open Benjamin-Dobell opened 4 years ago

Benjamin-Dobell commented 4 years ago

Stock Lua REPL

> print()

> print(table.unpack({}, 1, 0)) ​

MoonSharp REPL

> print()

> print(table.unpack({}, 1, 0)) nil

Looks like DynValue.NewTuple is the issue:

https://github.com/moonsharp-devs/moonsharp/blob/4e748a7a74af04b589af1b3e1aaa2d66d8b36a57/src/MoonSharp.Interpreter/DataTypes/DynValue.cs#L322-L323

However, other parts of MoonSharp are probably reliant on this behaviour.