this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

pkg: do not treat unknown Go types as adt.TopKind

We had one of these cases with pkg/time.Split, which returned
the type Parts, which is a struct. Declaring the result kind as
adt.TopKind works, but declaring it as adt.StructKind is more precise.

We no longer have a catch-all default, forcing us to handle all types
in the best way we can, much like adtKind does now.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Ie890f45c0918e0c2f18c5a60679fecebf7133fb4
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1201036
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+10 -3
+9 -2
pkg/gen.go
··· 408 408 case "io.Reader": 409 409 return "Reader" 410 410 case "error": 411 - return "Bottom" // for [generator.cueTypeExpression] 411 + return "Bottom" // for [generator.adtKind] 412 + 413 + // Some builtin functions return custom types, like [cuelang.org/go/pkg/time.Split]. 414 + // TODO: we can simplify this once the CUE API declarations in ./pkg/... 415 + // use CUE function signatures to validate their parameters and results. 416 + case "*cuelang.org/go/pkg/time.Parts": 417 + return "Struct" 412 418 } 413 - return "Value" // for [generator.cueTypeExpression] 419 + log.Fatal("unknown Go type: ", typ.String()) 420 + return "" 414 421 } 415 422 416 423 // adtKind provides a Go expression string which describes
+1 -1
pkg/time/pkg.go
··· 233 233 Params: []pkg.Param{ 234 234 {Kind: adt.StringKind}, 235 235 }, 236 - Result: adt.TopKind, 236 + Result: adt.StructKind, 237 237 Func: func(c *pkg.CallCtxt) { 238 238 t := c.String(0) 239 239 if c.Do() {