Skip to content

Conversation

@Akeit0
Copy link
Collaborator

@Akeit0 Akeit0 commented Mar 7, 2025

#77

@wmltogether
Copy link
Contributor

wmltogether commented Apr 9, 2025

Thank you for your fix. The issue with "or" has been resolved, but this piece of code cannot pass. Do we need to add some conditions in FunctionCompilationContext.PushOrMergeInstruction() when OpCode.Move ?

Exception:

Lua.LuaRuntimeException : @test_local.lua:10: attempt to index a 'Nil' value
   at Lua.LuaRuntimeException.AttemptInvalidOperation(Traceback traceback, String op, LuaValue a) in 

Lua:

sun = {}
sun.mass = 1

local bodies = { sun, sun, sun, sun, sun }

local function test_local(b, len)
    for i = 1, len do
        local bi = b[i]
        local bim = bi.mass
        print(bi.mass)
    end
end

local len = #bodies

test_local(bodies, len)


print"OK"
case OpCode.Move:

                if (
                    // available to merge and  last A is not local variable
                    lastInstruction.A == instruction.B && !activeLocals[lastInstruction.A])
                {
                    switch (lastInstruction.OpCode)
                    {
                        case OpCode.LoadK:
                        case OpCode.LoadBool when lastInstruction.C == 0:
                        case OpCode.LoadNil when lastInstruction.B == 0:
                        // remove these lines works?
                        //case OpCode.GetUpVal:
                        //case OpCode.GetTabUp:
                        //case OpCode.GetTable: 
                        //case OpCode.SetTabUp:
                        //case OpCode.SetUpVal:
                        //case OpCode.SetTable:
                        //case OpCode.NewTable:
                        case OpCode.Self:
                        case OpCode.Add:
                        case OpCode.Sub:

@Akeit0
Copy link
Collaborator Author

Akeit0 commented Apr 16, 2025

Thank you for your fix. The issue with "or" has been resolved, but this piece of code cannot pass. Do we need to add some conditions in FunctionCompilationContext.PushOrMergeInstruction() when OpCode.Move ?

For now, but the case you indicated has been dealt with and will be merged.

There may still be bugs, but this is a temporary fix as we are planning a full compiler overhaul.

@Akeit0 Akeit0 merged commit 7f868dc into nuskey8:main Apr 16, 2025
@Akeit0 Akeit0 deleted the fix-conditionals branch August 30, 2025 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants