lang: Don't block the engine for empty values

If the user passed an empty list or map, we should send that and not
block. This also includes a simple test to ensure this keeps working.
This commit is contained in:
James Shubin
2021-05-04 11:27:58 -04:00
parent 8a428c6936
commit 959084040d
3 changed files with 20 additions and 0 deletions

View File

@@ -119,6 +119,20 @@ func (obj *CompositeFunc) Stream() error {
select {
case input, ok := <-obj.init.Input:
if !ok {
obj.init.Input = nil // don't infinite loop back
if obj.last == nil {
// FIXME: can we get an empty struct?
result := obj.Type.New() // new list or map
obj.result = result
select {
case obj.init.Output <- result: // send
// pass
case <-obj.closeChan:
return nil
}
}
return nil // can't output any more
}
//if err := input.Type().Cmp(obj.Info().Sig.Input); err != nil {

View File

@@ -0,0 +1 @@
Vertex: test[name]

View File

@@ -0,0 +1,5 @@
# make sure the engine works with empty values
test "name" {
slicestring => [], # empty list
mapintfloat => {}, # empty map
}