From af04d364d01af502dcc52f1702ed91dd490a5d5a Mon Sep 17 00:00:00 2001 From: James Shubin Date: Sat, 5 Apr 2025 16:14:11 -0400 Subject: [PATCH] lang: core: fmt: Make printf handle more cases Until we make a clean determination about what this should print, this should handle things for now. --- lang/core/fmt/printf.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lang/core/fmt/printf.go b/lang/core/fmt/printf.go index 4a8faa42..769023d1 100644 --- a/lang/core/fmt/printf.go +++ b/lang/core/fmt/printf.go @@ -385,6 +385,19 @@ func valueToString(value types.Value) string { // TODO: use formatting flags ? // FIXME: Our String() method in FloatValue doesn't print nicely return value.String() + + case types.KindList: + fallthrough + case types.KindMap: + fallthrough + case types.KindStruct: + // XXX: Attempting to run value.Value() on a struct, which will + // surely have a lowercase (unexported) name will panic. This + // will also happen on any container types like list or map that + // may have a struct inside. It's expected that we have + // lowercase field names since we're using mcl, but workaround + // this panic for now with this cheap representation. + return value.String() } // FIXME: this is just an "easy-out" implementation for now...