diff --git a/lang/funcs/operator_func.go b/lang/funcs/operator_func.go index 00db6a23..018c54c6 100644 --- a/lang/funcs/operator_func.go +++ b/lang/funcs/operator_func.go @@ -883,10 +883,27 @@ func (obj *OperatorFunc) Stream(ctx context.Context) error { } obj.last = input // store for next + // programming error safety check... + programmingError := false + keys := []string{} + for k := range input.Struct() { + keys = append(keys, k) + if !util.StrInList(k, obj.Type.Ord) { + programmingError = true + } + } + if programmingError { + return fmt.Errorf("bad args, got: %v, want: %v", keys, obj.Type.Ord) + } + // build up arg list args := []types.Value{} for _, name := range obj.Type.Ord { - v := input.Struct()[name] + v, exists := input.Struct()[name] + if !exists { + // programming error + return fmt.Errorf("function engine was early, missing arg: %s", name) + } if name == operatorArgName { op = v.Str() continue // skip over the operator arg @@ -895,7 +912,8 @@ func (obj *OperatorFunc) Stream(ctx context.Context) error { } if op == "" { - return fmt.Errorf("operator cannot be empty") + // programming error + return fmt.Errorf("operator cannot be empty, args: %v", keys) } // operator selection is dynamic now, although mostly it // should not change... to do so is probably uncommon... diff --git a/lang/funcs/simple/simple.go b/lang/funcs/simple/simple.go index f9d4be05..28e83e71 100644 --- a/lang/funcs/simple/simple.go +++ b/lang/funcs/simple/simple.go @@ -84,7 +84,7 @@ type WrappedFunc struct { // String returns a simple name for this function. This is needed so this struct // can satisfy the pgraph.Vertex interface. func (obj *WrappedFunc) String() string { - return fmt.Sprintf("%s@%p", obj.Name, obj) // be more unique! + return fmt.Sprintf("%s @ %p", obj.Name, obj) // be more unique! } // ArgGen returns the Nth arg name for this function. diff --git a/lang/funcs/simplepoly/simplepoly.go b/lang/funcs/simplepoly/simplepoly.go index 26102cd1..d9f22a59 100644 --- a/lang/funcs/simplepoly/simplepoly.go +++ b/lang/funcs/simplepoly/simplepoly.go @@ -149,7 +149,7 @@ type WrappedFunc struct { // String returns a simple name for this function. This is needed so this struct // can satisfy the pgraph.Vertex interface. func (obj *WrappedFunc) String() string { - return fmt.Sprintf("%s@%p", obj.Name, obj) // be more unique! + return fmt.Sprintf("%s @ %p", obj.Name, obj) // be more unique! } // ArgGen returns the Nth arg name for this function. @@ -501,9 +501,8 @@ func (obj *WrappedFunc) buildFunction(typ *types.Type, ix int) *types.Type { panic("unexpected type") } obj.fn = fn - if obj.fn.T == nil { // XXX: should this even ever happen? What about argnames here? - obj.fn.T = typ.Copy() // overwrites any contained "variant" type - } + // FIXME: if obj.fn.T == nil {} // occasionally this is nil, is it a bug? + obj.fn.T = typ.Copy() // overwrites any contained "variant" type return obj.fn.T }