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:
@@ -42,10 +42,16 @@ func (obj *ConstFunc) Validate() error {
|
||||
|
||||
// Info returns some static info about itself.
|
||||
func (obj *ConstFunc) Info() *interfaces.Info {
|
||||
var typ *types.Type
|
||||
if obj.Value != nil { // don't panic if called speculatively
|
||||
if t := obj.Value.Type(); t != nil {
|
||||
typ = types.NewType(fmt.Sprintf("func() %s", t.String()))
|
||||
}
|
||||
}
|
||||
return &interfaces.Info{
|
||||
Pure: true,
|
||||
Memo: false, // TODO: ???
|
||||
Sig: types.NewType(fmt.Sprintf("func() %s", obj.Value.Type().String())),
|
||||
Sig: typ,
|
||||
Err: obj.Validate(), // XXX: implement this and check .Err in engine!
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user