diff --git a/pkg/gen.go b/pkg/gen.go index d126a9e29..979d9a1a7 100644 --- a/pkg/gen.go +++ b/pkg/gen.go @@ -410,7 +410,17 @@ func (g *generator) callCtxtGetter(typ types.Type) string { case "error": return "Bottom" // for [generator.cueTypeExpression] } - return "Value" // for [generator.cueTypeExpression] + // Some builtin functions return custom types, like [cuelang.org/go/pkg/time.Split]. + // Inspect the underlying type behind any pointer and return an appropriate shape. + if ptr, ok := typ.(*types.Pointer); ok { + typ = ptr.Elem() + } + switch typ.Underlying().(type) { + case *types.Struct: // e.g. [cuelang.org/go/pkg/time.Parts] + return "Struct" + } + log.Fatal("unknown Go type: ", typ.String()) + return "" } // adtKind provides a Go expression string which describes diff --git a/pkg/time/pkg.go b/pkg/time/pkg.go index 80a3a17ef..6ed8ff7aa 100644 --- a/pkg/time/pkg.go +++ b/pkg/time/pkg.go @@ -233,7 +233,7 @@ var p = &pkg.Package{ Params: []pkg.Param{ {Kind: adt.StringKind}, }, - Result: adt.TopKind, + Result: adt.StructKind, Func: func(c *pkg.CallCtxt) { t := c.String(0) if c.Do() {