From 3342c04d06192db3f11ea25699ff81d248f5b1eb Mon Sep 17 00:00:00 2001 From: James Shubin Date: Sun, 8 Dec 2024 13:50:04 -0500 Subject: [PATCH] lang: funcs: structs: Improve naming These could print nicer for debugging. --- lang/funcs/structs/composite.go | 3 +++ lang/funcs/structs/const.go | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lang/funcs/structs/composite.go b/lang/funcs/structs/composite.go index 93f97b5e3..0dccef905 100644 --- a/lang/funcs/structs/composite.go +++ b/lang/funcs/structs/composite.go @@ -59,6 +59,9 @@ type CompositeFunc struct { // String returns a simple name for this function. This is needed so this struct // can satisfy the pgraph.Vertex interface. func (obj *CompositeFunc) String() string { + if obj.Type != nil { + return fmt.Sprintf("%s: %s", CompositeFuncName, obj.Type.String()) + } return CompositeFuncName } diff --git a/lang/funcs/structs/const.go b/lang/funcs/structs/const.go index 504eb4c6d..3d61325fb 100644 --- a/lang/funcs/structs/const.go +++ b/lang/funcs/structs/const.go @@ -56,9 +56,10 @@ func (obj *ConstFunc) String() string { if obj.NameHint != "" { return obj.NameHint } + if obj.Value != nil && obj.Value.Type() != nil { + return fmt.Sprintf("%s: %s(%s)", ConstFuncName, obj.Value.Type().String(), obj.Value.String()) + } return ConstFuncName - //return fmt.Sprintf("%s: %s(%s)", ConstFuncName, obj.Value.Type().String(), obj.Value.String()) - //return fmt.Sprintf("%s(%s)", obj.Value.Type().String(), obj.Value.String()) } // Validate makes sure we've built our struct properly.