Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Lua/Runtime/LuaVirtualMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2666,6 +2666,7 @@ out metamethod
{
var RA = context.Instruction.A + context.FrameBase;
stack.Get(RA) = table.ArrayLength;
stack.NotifyTop(RA + 1);
return true;
}

Expand Down
1 change: 1 addition & 0 deletions tests/Lua.Tests/LuaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ static string PatchFilesLuaSource(string source)
[TestCase("tests-lua/coroutine.lua")]
[TestCase("tests-lua/db.lua")]
[TestCase("tests-lua/verybig.lua")]
[TestCase("tests-lua/table-length.lua")]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although not explicitly stated, LuaTests (tests-lua) is a port of the official Lua tests; therefore, if possible, please write dedicated test in the appropriate classes.

public async Task Test_Lua(string file)
{
var path = FileHelper.GetAbsolutePath(file);
Expand Down
11 changes: 11 additions & 0 deletions tests/Lua.Tests/tests-lua/table-length.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function f1()
local c = {}
return #c
end

function f2(a, b)
assert(b == nil)
end

f1()
f2()