lang: Functions that build should be copyable

It's not entirely clear if this is required, but it's probably a good
idea. We should consider making it a requirement of the BuildableFunc
interface.
This commit is contained in:
James Shubin
2025-04-19 21:21:19 -04:00
parent 1bb1e056c4
commit 1536a94026
10 changed files with 112 additions and 0 deletions

View File

@@ -393,6 +393,17 @@ func (obj *TemplateFunc) Stream(ctx context.Context) error {
}
}
// Copy is implemented so that the obj.built value is not lost if we copy this
// function.
func (obj *TemplateFunc) Copy() interfaces.Func {
return &TemplateFunc{
Type: obj.Type, // don't copy because we use this after unification
built: obj.built,
init: obj.init, // likely gets overwritten anyways
}
}
// Call this function with the input args and return the value if it is possible
// to do so at this time.
func (obj *TemplateFunc) Call(ctx context.Context, args []types.Value) (types.Value, error) {