lang: interfaces: Nil input means no args

This commit is contained in:
James Shubin
2024-10-06 22:51:48 -04:00
parent 6c12e8a29b
commit b03fdeccae

View File

@@ -391,8 +391,9 @@ type Txn interface {
// StructToCallableArgs transforms the single value, graph representation of the
// callable values into a linear, standard args list.
func StructToCallableArgs(st types.Value) ([]types.Value, error) {
if st == nil {
return nil, fmt.Errorf("empty struct")
args := []types.Value{}
if st == nil { // for functions that take no args
return args, nil
}
typ := st.Type()
if typ == nil {
@@ -406,7 +407,6 @@ func StructToCallableArgs(st types.Value) ([]types.Value, error) {
return nil, fmt.Errorf("empty values")
}
args := []types.Value{}
for i, x := range typ.Ord { // in the correct order
v, exists := structValues[x]
if !exists {