From de7198e9dc01fb2e04a4db92d4196c7080bc6f28 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Tue, 18 May 2021 02:04:33 -0400 Subject: [PATCH] lang: funcs: Check for functions that haven't been migrated All polymorphic functions should use the new API, at least until we either implement a compat wrapper. But it's probably best if we get rid of the old API as soon as we make all this type unification work properly. --- lang/funcs/funcs.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lang/funcs/funcs.go b/lang/funcs/funcs.go index 7647f88f..7684888f 100644 --- a/lang/funcs/funcs.go +++ b/lang/funcs/funcs.go @@ -72,6 +72,13 @@ func Register(name string, fn func() interfaces.Func) { // panic(fmt.Sprintf("a func named %s is invalid", name)) //} + fnx := fn() // check that all functions have migrated to the new API! + if _, ok := fnx.(interfaces.OldPolyFunc); ok { + if _, ok := fnx.(interfaces.PolyFunc); !ok { + panic(fmt.Sprintf("a func named %s implements OldPolyFunc but not PolyFunc", name)) + } + } + //gob.Register(fn()) registeredFuncs[name] = fn }