neolithos / neolua

A Lua implementation for the Dynamic Language Runtime (DLR).
https://neolua.codeplex.com/
Apache License 2.0
466 stars 76 forks source link

Problem with using C# UInt32 variable as a lua table key ("No conversion defined from UInt32 to indexKey") #134

Closed Nevlabs closed 2 years ago

Nevlabs commented 3 years ago

NeoLua Version: 1.3.13 Example to reproduce: uint key = 2; var code = @" local tbl = {} tbl[key] = 5 return tbl[key]";

var lua = new Lua(); dynamic env = lua.CreateEnvironment(); env.key = key; var chunk = lua.CompileChunk(code, "lua.lua", new LuaCompileOptions()); var r = env.dochunk(chunk);

Works fine if key type would be int or ushort.

neolithos commented 3 years ago

The array part of the lua table is only design for integer. All types that are fit in an integer are okay. UInt32, UInt64 and Int64 are an problem and will result in exceptions.

I did a little fix. Now it works, but it will result in endless loops? I need more test cases for these part.

neolithos commented 3 years ago

Now it should work as intented.