From d37862b1234b0c77da9f92a8a9edeb4f896c55d3 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Thu, 29 Jun 2023 15:31:12 -0400 Subject: [PATCH] lang: funcs: Use more constants to build types --- lang/funcs/contains_polyfunc.go | 2 +- lang/funcs/core/world/schedule_func.go | 4 ++-- lang/funcs/history_polyfunc.go | 2 +- lang/funcs/maplookup_polyfunc.go | 2 +- lang/funcs/structlookup_polyfunc.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lang/funcs/contains_polyfunc.go b/lang/funcs/contains_polyfunc.go index 1c0f74c8..28a51936 100644 --- a/lang/funcs/contains_polyfunc.go +++ b/lang/funcs/contains_polyfunc.go @@ -348,7 +348,7 @@ func (obj *ContainsPolyFunc) Info() *interfaces.Info { var sig *types.Type if obj.Type != nil { // don't panic if called speculatively s := obj.Type.String() - sig = types.NewType(fmt.Sprintf("func(needle %s, haystack []%s) bool", s, s)) + sig = types.NewType(fmt.Sprintf("func(%s %s, %s []%s) bool", containsArgNameNeedle, s, containsArgNameHaystack, s)) } return &interfaces.Info{ Pure: true, diff --git a/lang/funcs/core/world/schedule_func.go b/lang/funcs/core/world/schedule_func.go index fabe9169..b102b913 100644 --- a/lang/funcs/core/world/schedule_func.go +++ b/lang/funcs/core/world/schedule_func.go @@ -500,9 +500,9 @@ func (obj *SchedulePolyFunc) Info() *interfaces.Info { // before you're built. Type unification may call it opportunistically. var typ *types.Type if obj.built { - typ = types.NewType("func(namespace str) []str") // simplest form + typ = types.NewType(fmt.Sprintf("func(%s str) []str", scheduleArgNameNamespace)) // simplest form if obj.Type != nil { - typ = types.NewType(fmt.Sprintf("func(namespace str, opts %s) []str", obj.Type.String())) + typ = types.NewType(fmt.Sprintf("func(%s str, %s %s) []str", scheduleArgNameNamespace, scheduleArgNameOpts, obj.Type.String())) } } return &interfaces.Info{ diff --git a/lang/funcs/history_polyfunc.go b/lang/funcs/history_polyfunc.go index f51bc0c7..2d5a7e1b 100644 --- a/lang/funcs/history_polyfunc.go +++ b/lang/funcs/history_polyfunc.go @@ -345,7 +345,7 @@ func (obj *HistoryFunc) Info() *interfaces.Info { var sig *types.Type if obj.Type != nil { // don't panic if called speculatively s := obj.Type.String() - sig = types.NewType(fmt.Sprintf("func(value %s, index int) %s", s, s)) + sig = types.NewType(fmt.Sprintf("func(%s %s, %s int) %s", historyArgNameValue, s, historyArgNameIndex, s)) } return &interfaces.Info{ Pure: false, // definitely false diff --git a/lang/funcs/maplookup_polyfunc.go b/lang/funcs/maplookup_polyfunc.go index 180b8332..878f128b 100644 --- a/lang/funcs/maplookup_polyfunc.go +++ b/lang/funcs/maplookup_polyfunc.go @@ -534,7 +534,7 @@ func (obj *MapLookupPolyFunc) Info() *interfaces.Info { // TODO: can obj.Type.Key or obj.Type.Val be nil (a partial) ? k := obj.Type.Key.String() v := obj.Type.Val.String() - typ = types.NewType(fmt.Sprintf("func(map %s, key %s, default %s) %s", obj.Type.String(), k, v, v)) + typ = types.NewType(fmt.Sprintf("func(%s %s, %s %s, %s %s) %s", mapLookupArgNameMap, obj.Type.String(), mapLookupArgNameKey, k, mapLookupArgNameDef, v, v)) } return &interfaces.Info{ Pure: true, diff --git a/lang/funcs/structlookup_polyfunc.go b/lang/funcs/structlookup_polyfunc.go index f0ca5649..583b3b78 100644 --- a/lang/funcs/structlookup_polyfunc.go +++ b/lang/funcs/structlookup_polyfunc.go @@ -459,7 +459,7 @@ func (obj *StructLookupPolyFunc) Info() *interfaces.Info { var sig *types.Type if obj.Type != nil { // don't panic if called speculatively // TODO: can obj.Out be nil (a partial) ? - sig = types.NewType(fmt.Sprintf("func(struct %s, field str) %s", obj.Type.String(), obj.Out.String())) + sig = types.NewType(fmt.Sprintf("func(%s %s, %s str) %s", structLookupArgNameStruct, obj.Type.String(), structLookupArgNameField, obj.Out.String())) } return &interfaces.Info{ Pure: true,