ysmood/got

tokenize panics when comparing array with Gt()

rustysys-dev opened this issue · 1 comments

This used to work in v0.15.1 but after upgrade to v0.31.3 the following line causes a panic at tokenize. I don't know if this is an expected outcome or not, but wanted to mention it.

t.Gt(j.Get("merchants").Arr(), 0)

panic:

         each.go:110: [panic] runtime error: index out of range [7] with length 7
            goroutine 77 [running]:
            runtime/debug.Stack()
                /home/rusty/go/src/runtime/debug/stack.go:24 +0x65
            github.com/ysmood/got.callMethod.func1()
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/each.go:110 +0x58
            panic({0xbbedc0, 0xc0006abf98})
                /home/rusty/go/src/runtime/panic.go:838 +0x207
            github.com/ysmood/got/lib/gop.path.has(...)
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:121
            github.com/ysmood/got/lib/gop.seen.circular(0xaf05c0?, {0xc000230700, 0x7, 0x8}, {0xaf05c0?, 0xc00086d788?, 0x10?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:138 +0x5f9
            github.com/ysmood/got/lib/gop.tokenize(0xb1d080?, {0xc000230700, 0x7, 0x8}, {0xaf05c0?, 0xc00086d788?, 0xc0007f0570?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:155 +0xc5
            github.com/ysmood/got/lib/gop.tokenize(0xb324c0?, {0xc000230700, 0x7, 0x8}, {0xb1d080?, 0xc000b18e30?, 0xc000168998?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:163 +0x554
            github.com/ysmood/got/lib/gop.tokenizeCollection(0xb324c0?, {0xc000230700, 0x6, 0x8}, {0xb324c0?, 0xc0006bd4d0?, 0x10?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:267 +0x196d
            github.com/ysmood/got/lib/gop.tokenize(0xb1d080?, {0xc000230700, 0x6, 0x8}, {0xb324c0?, 0xc0006bd4d0?, 0xc0007f0b08?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:206 +0xcde
            github.com/ysmood/got/lib/gop.tokenize(0xb324c0?, {0xc000230700, 0x6, 0x8}, {0xb1d080?, 0xc000b18dd0?, 0xc000af7ee8?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:163 +0x554
            github.com/ysmood/got/lib/gop.tokenizeCollection(0xb324c0?, {0xc000230700, 0x5, 0x8}, {0xb324c0?, 0xc0006bd2f0?, 0x10?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:267 +0x196d
            github.com/ysmood/got/lib/gop.tokenize(0xb1d080?, {0xc000230700, 0x5, 0x8}, {0xb324c0?, 0xc0006bd2f0?, 0xc0007f10a0?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:206 +0xcde
            github.com/ysmood/got/lib/gop.tokenize(0xb324c0?, {0xc000230700, 0x5, 0x8}, {0xb1d080?, 0xc00015fb90?, 0x80?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:163 +0x554
            github.com/ysmood/got/lib/gop.tokenizeCollection(0xb324c0?, {0xc000c95040, 0x4, 0x4}, {0xb324c0?, 0xc0006bd260?, 0x42ea5b?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:267 +0x196d
            github.com/ysmood/got/lib/gop.tokenize(0xb1d080?, {0xc000c95040, 0x4, 0x4}, {0xb324c0?, 0xc0006bd260?, 0x100c000af7718?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:206 +0xcde
            github.com/ysmood/got/lib/gop.tokenize(0xaf05c0?, {0xc000c95040, 0x4, 0x4}, {0xb1d080?, 0xc0006c0f50?, 0xc000af77e8?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:163 +0x554
            github.com/ysmood/got/lib/gop.tokenizeCollection(0xaf05c0?, {0xc000c95040, 0x3, 0x4}, {0xaf05c0?, 0xc00086d800?, 0x8?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:247 +0x12b5
            github.com/ysmood/got/lib/gop.tokenize(0xb1d080?, {0xc000c95040, 0x3, 0x4}, {0xaf05c0?, 0xc00086d800?, 0xc0007f1bd0?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:206 +0xcde
            github.com/ysmood/got/lib/gop.tokenize(0xb324c0?, {0xc000c95040, 0x3, 0x4}, {0xb1d080?, 0xc00015f460?, 0x20?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:163 +0x554
            github.com/ysmood/got/lib/gop.tokenizeCollection(0xb324c0?, {0xc000592de0, 0x2, 0x2}, {0xb324c0?, 0xc0006bd230?, 0xc0007f1f98?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:267 +0x196d
            github.com/ysmood/got/lib/gop.tokenize(0xb1d080?, {0xc000592de0, 0x2, 0x2}, {0xb324c0?, 0xc0006bd230?, 0x200?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:206 +0xcde
            github.com/ysmood/got/lib/gop.tokenize(0xae47a0?, {0xc000592de0, 0x2, 0x2}, {0xb1d080?, 0xc0006c1230?, 0xc0007f22b0?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:163 +0x554
            github.com/ysmood/got/lib/gop.tokenizePtr(0xae47a0?, {0xc000592de0, 0x2, 0x2}, {0xae47a0?, 0xc00015f3c8?, 0x40f3e5?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:441 +0x487
            github.com/ysmood/got/lib/gop.tokenize(0xb1d080?, {0xc000592de0, 0x2, 0x2}, {0xae47a0?, 0xc00015f3c8?, 0x0?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:193 +0xc85
            github.com/ysmood/got/lib/gop.tokenizeCollection(0xbe3ca0?, {0xc00015f290, 0x1, 0x1}, {0xbe3ca0?, 0xc0005c02e0?, 0x7f6a8a6dc200?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:287 +0xe1f
            github.com/ysmood/got/lib/gop.tokenize(0xaee5c0?, {0xc00015f290, 0x1, 0x1}, {0xbe3ca0?, 0xc0005c02e0?, 0xafdbe0?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:206 +0xcde
            github.com/ysmood/got/lib/gop.tokenizeCollection(0xaee5c0?, {0x125dab8, 0x0, 0x0}, {0xaee5c0?, 0xc00086d9e0?, 0x7f6a8a6a2200?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:247 +0x12b5
            github.com/ysmood/got/lib/gop.tokenize(0x0?, {0x125dab8, 0x0, 0x0}, {0xaee5c0?, 0xc00086d9e0?, 0xc0006a2f18?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:206 +0xcde
            github.com/ysmood/got/lib/gop.Tokenize({0xaee5c0?, 0xc00086d9e0?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/token.go:102 +0x12e
            github.com/ysmood/got/lib/gop.Plain({0xaee5c0?, 0xc00086d9e0?})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/gop/format.go:75 +0x25
            github.com/ysmood/got/lib/utils.Compare({0xaee5c0?, 0xc00086d9e0?}, {0xafd260, 0xd2e848})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/utils/utils.go:39 +0x31
            github.com/ysmood/got/lib/utils.SmartCompare({0xaee5c0?, 0xc00086d9e0}, {0xafd260?, 0xd2e848})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/lib/utils/utils.go:34 +0x43f
            github.com/ysmood/got.Assertions.Gt({{0xd3a1c0, 0xc000642d00}, {0xd30d00, 0xc0005b6030}, 0x0, {0x0, 0x0}}, {0xaee5c0?, 0xc00086d9e0}, {0xafd260, ...})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/assertions.go:78 +0x97
            github.com/zeals-co-ltd/dx-reservation/pkg/admin_test.T.ManageConfigViaUserAccount({{{0xd3a1c0, 0xc000642d00}, {{0xd3a1c0, 0xc000642d00}, {0xd30d00, 0xc0005b6030}, 0x0, {0x0, 0x0}}, {{0xd3a1c0, ...}}}, ...})
                /home/rusty/Documents/repo/dx-reservation/pkg/admin/basic_test.go:56 +0x51f
            reflect.Value.call({0xc0008b9860?, 0xc000010e28?, 0x7f6ab1194108?}, {0xc0a7d6, 0x4}, {0xc000bb8b10, 0x1, 0x0?})
                /home/rusty/go/src/reflect/value.go:556 +0x845
            reflect.Value.Call({0xc0008b9860?, 0xc000010e28?, 0x0?}, {0xc000bb8b10, 0x1, 0x1})
                /home/rusty/go/src/reflect/value.go:339 +0xbf
            github.com/ysmood/got.callMethod({0xd3a1c0, 0xc000642d00}, {{0xac4be9, 0x1a}, {0x0, 0x0}, {0xd3c5e0, 0xc0008b9860}, {0xc0008b9860, 0xc000010e28, ...}, ...}, ...)
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/each.go:115 +0x211
            github.com/ysmood/got.Each.func1({0xc000bb8108, 0x1, 0x1})
                /home/rusty/go/pkg/mod/github.com/ysmood/got@v0.31.3/each.go:48 +0x18e
            testing.tRunner(0xc000642d00, 0xc0001467e0)
                /home/rusty/go/src/testing/testing.go:1439 +0x102
            created by testing.(*T).Run
                /home/rusty/go/src/testing/testing.go:1486 +0x35f

workaround:

t.Gt(len(j.Get("merchants").Arr()), 0)

Should be fixed in v0.31.3