We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents ab39c60 + a519e4d commit 36862c5Copy full SHA for 36862c5
auxlib.go
@@ -48,6 +48,8 @@ func (ls *LState) CheckString(n int) string {
48
v := ls.Get(n)
49
if lv, ok := v.(LString); ok {
50
return string(lv)
51
+ } else if LVCanConvToString(v) {
52
+ return ls.ToString(n)
53
}
54
ls.TypeError(n, LTString)
55
return ""
auxlib_test.go
@@ -49,9 +49,11 @@ func TestCheckString(t *testing.T) {
L.Push(LString("aaa"))
errorIfNotEqual(t, "aaa", L.CheckString(2))
L.Push(LNumber(10))
- L.CheckString(3)
+ errorIfNotEqual(t, "10", L.CheckString(3))
+ L.Push(L.NewTable())
+ L.CheckString(4)
return 0
- }, "string expected, got number")
56
+ }, "string expected, got table")
57
58
59
func TestCheckBool(t *testing.T) {
0 commit comments