Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The parameter passed by xpcall is nil #454

Open
CNicer opened this issue Aug 31, 2023 · 0 comments
Open

The parameter passed by xpcall is nil #454

CNicer opened this issue Aug 31, 2023 · 0 comments

Comments

@CNicer
Copy link

CNicer commented Aug 31, 2023

GopherLua v1.1.0
go v1.21.0 linux/amd64

I defiend a global function called testfunc in lua, testfunc calls function test through xpcall and passes in a parameter, but the fucntion called with xpcall displays Msg as nil, but pcall is normal

lua code:

function _G.testfunc()
    xpcall(test, debug.traceback, "Hello World")
    pcall(test, "Hello World")
end

function test(Msg)
    if Msg == nil then
        print("msg is nil")
        return
    end

    LogInfo("msg ", Msg)
end

and go code

h.L.CallByParam(lua.P{
  Fn:   h.L.GetGlobal("testfunc"),
  NRet: 0,
})

and the log shows:
image

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

No branches or pull requests

1 participant