lang: funcs: facts: Check if a fact is callable

This commit is contained in:
James Shubin
2025-03-17 02:28:06 -04:00
parent b4769eefd9
commit e71b11f843

View File

@@ -97,5 +97,12 @@ func (obj *FactFunc) Stream(ctx context.Context) error {
// Call this fact and return the value if it is possible to do so at this time. // Call this fact and return the value if it is possible to do so at this time.
func (obj *FactFunc) Call(ctx context.Context, _ []types.Value) (types.Value, error) { func (obj *FactFunc) Call(ctx context.Context, _ []types.Value) (types.Value, error) {
return obj.Fact.Call(ctx) //return obj.Fact.Call(ctx)
callableFact, ok := obj.Fact.(CallableFact)
if !ok {
return nil, fmt.Errorf("fact is not a CallableFact")
}
return callableFact.Call(ctx)
} }