-
Notifications
You must be signed in to change notification settings - Fork 60
Closed
Labels
Description
Great library!
Saw the following panic in my usage:
package main
import (
art "github.com/plar/go-adaptive-radix-tree"
)
func main() {
tree := art.New()
tree.Insert(art.Key("Hi, I'm Key"), "Nice to meet you, I'm Value")
tree.Insert(art.Key(nil), "Meet you again")
tree.Insert(art.Key(nil), "Meet you again") // panic
}https://go.dev/play/p/G6tYWq0QzpJ
And the resulting trace:
panic: runtime error: slice bounds out of range [1:0]
goroutine 1 [running]:
github.com/plar/go-adaptive-radix-tree.(*tree).recursiveInsert(0xc00009ae60?, 0xc000106050, {0x0, 0x0, 0x0}, {0x46e6e0?, 0x496e98}, 0x1)
/tmp/gopath331505154/pkg/mod/github.com/plar/go-adaptive-radix-tree@v1.0.4/tree.go:120 +0x5d7
github.com/plar/go-adaptive-radix-tree.(*tree).recursiveInsert(0xc00010a000?, 0xc00009af60, {0x0, 0x0, 0x0}, {0x46e6e0?, 0x496e98}, 0x0)
/tmp/gopath331505154/pkg/mod/github.com/plar/go-adaptive-radix-tree@v1.0.4/tree.go:175 +0x293
github.com/plar/go-adaptive-radix-tree.(*tree).Insert(0xc00009af58, {0x0?, 0x404bd9?, 0x60?}, {0x46e6e0?, 0x496e98?})
/tmp/gopath331505154/pkg/mod/github.com/plar/go-adaptive-radix-tree@v1.0.4/tree.go:15 +0x48
main.main()
/tmp/sandbox249177140/prog.go:12 +0xc5
Looking to investigate further, the documentation hints that nil should be supported as a key.