From 2c88c33f6b3a63c98b737a667262a2ea1a11b9a6 Mon Sep 17 00:00:00 2001 From: Dmitry Ng Date: Tue, 21 Sep 2021 22:52:46 +0300 Subject: [PATCH] Bump of golua version up to v1.1.0 --- go.mod | 2 +- go.sum | 4 ++-- luar_test.go | 9 +++++++-- proxymm.go | 10 ++++++---- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index e49537b..bddf9eb 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,4 @@ module github.com/vxcontrol/luar go 1.13 -require github.com/vxcontrol/golua v1.0.0 +require github.com/vxcontrol/golua v1.1.0 diff --git a/go.sum b/go.sum index d6a9dd2..2210932 100644 --- a/go.sum +++ b/go.sum @@ -4,7 +4,7 @@ github.com/modern-go/gls v0.0.0-20190610040709-84558782a674 h1:1n+vuTzNkmbDn73+c github.com/modern-go/gls v0.0.0-20190610040709-84558782a674/go.mod h1:I8AX+yW//L8Hshx6+a1m3bYkwXkpsVjA2795vP4f4oQ= github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/vxcontrol/golua v1.0.0 h1:EVv0odsxnHMXLyBP9h9tMvtM3tX2QRc43AMkkBcUwEo= -github.com/vxcontrol/golua v1.0.0/go.mod h1:2eE5/byEyZ2lpsCGtIuNqV7O5PiG9r+MIa747aMBZiI= +github.com/vxcontrol/golua v1.1.0 h1:0Toe564yyUJ9hD7wl4JB+hHQLtlT3fZAC3JP+NK/DAU= +github.com/vxcontrol/golua v1.1.0/go.mod h1:2eE5/byEyZ2lpsCGtIuNqV7O5PiG9r+MIa747aMBZiI= github.com/vxcontrol/rmx v0.0.0-20210315190445-0c5e1f972da6 h1:a4ML+o1WlNw8gOGautso1TTfETirOsUNC0Xpr+yWQLo= github.com/vxcontrol/rmx v0.0.0-20210315190445-0c5e1f972da6/go.mod h1:tWgKOCwhzgp7K6XMYelYlTqB/v4/VubHgr2WOmd3XFI= diff --git a/luar_test.go b/luar_test.go index cf5d032..d1dd7d4 100644 --- a/luar_test.go +++ b/luar_test.go @@ -1,6 +1,7 @@ package luar import ( + "fmt" "reflect" "runtime" "sort" @@ -711,7 +712,7 @@ func TestLuaObjectMT(t *testing.T) { // Note: we skip error checking. v, _ := valueOfProxy(L, 1) k := L.ToInteger(2) - L.PushString(string(v.Index(k).Int())) + L.PushString(fmt.Sprintf("%c", v.Index(k).Int())) return 1 } @@ -866,9 +867,13 @@ setmetatable(a, { __call = function(arg) a[1] = a[1] + arg end }) err = a.Call(nil) wantErr := "[string \"...\"]:3: attempt to perform arithmetic on local 'arg' (a nil value)" - if err == nil || err.Error() != wantErr { + if err == nil { + t.Fatal("panic on lua Call must be catched") + } + if le, ok := err.(*lua.LuaError); !ok || le.Msg != wantErr { t.Fatalf("got error %q, want %q", err, wantErr) } + checkStack(t, L) } diff --git a/proxymm.go b/proxymm.go index 2c3b050..ac6b8d0 100644 --- a/proxymm.go +++ b/proxymm.go @@ -331,10 +331,12 @@ func proxy__eq(L *lua.State) int { } func proxy__gc(L *lua.State) int { - proxyId := *(*uintptr)(L.ToUserdata(1)) - proxymu.Lock() - delete(proxyMap, proxyId) - proxymu.Unlock() + if ud := L.ToUserdata(1); ud != nil { + proxyId := *(*uintptr)(ud) + proxymu.Lock() + delete(proxyMap, proxyId) + proxymu.Unlock() + } return 0 }