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.
This commit is contained in:
@@ -48,6 +48,10 @@ func Register(name string, fn *types.FuncValue) {
|
|||||||
if fn.T == nil {
|
if fn.T == nil {
|
||||||
panic(fmt.Sprintf("simple func %s contains a nil type signature", name))
|
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
|
RegisteredFuncs[name] = fn // store a copy for ourselves
|
||||||
|
|
||||||
// register a copy in the main function database
|
// register a copy in the main function database
|
||||||
|
|||||||
Reference in New Issue
Block a user