lang: funcs: Ensure that Info sig's are invalid if not built yet

In case something in the type unification tries to speculatively call
Info before it's ready to produce a valid sig, make sure we only return
a definitive answer (non-nil, and no variant types) once we've
conclusively finished defining the signature.
This commit is contained in:
James Shubin
2021-05-19 10:33:35 -04:00
parent b3d1ed9e65
commit 95cfbd0fff
7 changed files with 68 additions and 44 deletions

View File

@@ -218,14 +218,15 @@ func (obj *WrappedFunc) Validate() error {
// Info returns some static info about itself.
func (obj *WrappedFunc) Info() *interfaces.Info {
var sig *types.Type
var typ *types.Type
if obj.fn != nil { // don't panic if called speculatively
sig = obj.fn.Type()
typ = obj.fn.Type()
}
return &interfaces.Info{
Pure: true,
Memo: false, // TODO: should this be something we specify here?
Sig: sig,
Sig: typ,
Err: obj.Validate(),
}
}