From eb1053607a0a0f3a1e0dd45802c826b5f085e6bf Mon Sep 17 00:00:00 2001 From: James Shubin Date: Sun, 23 May 2021 16:54:55 -0400 Subject: [PATCH] lang: funcs: simple: Check for variant signatures This adds a safety check in case someone sneaks in a variant type in the simple function signature. These might be sneaky to detect, and it's simpler to catch them right here. From a design point of view, we might consider actually permitting these, like we did with the simple poly API, but it's probably better for them to get implemented in that API instead (if we decide to allow this long-term) and keep this simple API very simple. --- lang/funcs/simple/simple.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lang/funcs/simple/simple.go b/lang/funcs/simple/simple.go index f5b049f5..44d006df 100644 --- a/lang/funcs/simple/simple.go +++ b/lang/funcs/simple/simple.go @@ -48,6 +48,10 @@ func Register(name string, fn *types.FuncValue) { if fn.T == nil { panic(fmt.Sprintf("simple func %s contains a nil type signature", name)) } + if fn.T.HasVariant() { + panic(fmt.Sprintf("simple func %s contains a variant type signature", name)) + } + RegisteredFuncs[name] = fn // store a copy for ourselves // register a copy in the main function database