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.
This commit is contained in:
James Shubin
2021-05-18 02:04:33 -04:00
parent 0f30f47249
commit de7198e9dc

View File

@@ -72,6 +72,13 @@ func Register(name string, fn func() interfaces.Func) {
// panic(fmt.Sprintf("a func named %s is invalid", name)) // 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()) //gob.Register(fn())
registeredFuncs[name] = fn registeredFuncs[name] = fn
} }