From 3b608ad5447105bff40e2f35dae0786afb85e7bf Mon Sep 17 00:00:00 2001 From: James Shubin Date: Wed, 22 May 2019 13:14:07 -0400 Subject: [PATCH] lang: funcs: Verify that simple polyfunc list is not empty This could prevent some incorrect usage of the simplepoly API. --- lang/funcs/simplepoly/simplepoly.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lang/funcs/simplepoly/simplepoly.go b/lang/funcs/simplepoly/simplepoly.go index b54883fd..8f4e4e82 100644 --- a/lang/funcs/simplepoly/simplepoly.go +++ b/lang/funcs/simplepoly/simplepoly.go @@ -42,6 +42,10 @@ func Register(name string, fns []*types.FuncValue) { panic(fmt.Sprintf("a simple polyfunc named %s is already registered", name)) } + if len(fns) == 0 { + panic("no functions specified for simple polyfunc") + } + // check for uniqueness in type signatures typs := []*types.Type{} for _, f := range fns {