diff --git a/cue/load/config.go b/cue/load/config.go index a81ce9563..6a8473249 100644 --- a/cue/load/config.go +++ b/cue/load/config.go @@ -395,7 +395,7 @@ func (c *Config) absDirFromImportPath(pos token.Pos, p importPath) (absDir, name absDir = filepath.Join(GenPath(c.ModuleRoot), sub) } - return absDir, name, nil + return absDir, name, err } // Complete updates the configuration information. After calling complete, diff --git a/encoding/openapi/openapi.go b/encoding/openapi/openapi.go index f26cff6e7..6eaebb8ca 100644 --- a/encoding/openapi/openapi.go +++ b/encoding/openapi/openapi.go @@ -133,27 +133,29 @@ func (c *Config) compose(inst *cue.Instance, schemas *ast.StructLit) (x *ast.Str var info *ast.StructLit for i, _ := inst.Value().Fields(cue.Definitions(true)); i.Next(); { - if !i.IsDefinition() { - label := i.Label() - attr := i.Value().Attribute("openapi") - if s, _ := attr.String(0); s != "" { - label = s - } - switch label { - case "-": - case "info": - info, _ = i.Value().Syntax().(*ast.StructLit) - if info == nil { - errs = errors.Append(errs, errors.Newf(i.Value().Pos(), - "info must be a struct")) - } - title, _ = i.Value().Lookup("title").String() - version, _ = i.Value().Lookup("version").String() - - default: + if i.IsDefinition() { + continue + } + label := i.Label() + attr := i.Value().Attribute("openapi") + if s, _ := attr.String(0); s != "" { + label = s + } + switch label { + case "$version": + case "-": + case "info": + info, _ = i.Value().Syntax().(*ast.StructLit) + if info == nil { errs = errors.Append(errs, errors.Newf(i.Value().Pos(), - "openapi: unsupported top-level field %q", x)) + "info must be a struct")) } + title, _ = i.Value().Lookup("title").String() + version, _ = i.Value().Lookup("version").String() + + default: + errs = errors.Append(errs, errors.Newf(i.Value().Pos(), + "openapi: unsupported top-level field %q", label)) } } @@ -210,7 +212,7 @@ func (c *Config) compose(inst *cue.Instance, schemas *ast.StructLit) (x *ast.Str "info", info, "paths", ast.NewStruct(), "components", ast.NewStruct("schemas", schemas), - ), nil + ), errs } // Schemas extracts component/schemas from the CUE top-level types. diff --git a/internal/cuetest/sim.go b/internal/cuetest/sim.go index 2d527ac66..51aa95d17 100644 --- a/internal/cuetest/sim.go +++ b/internal/cuetest/sim.go @@ -65,6 +65,9 @@ func Run(t *testing.T, dir, command string, cfg *Config) { cfg.Stdout = buf } cmd, err := cmd.New(args) + if err != nil { + t.Fatal(err) + } if cfg.Stdout != nil { cmd.SetOutput(cfg.Stdout) } else { diff --git a/pkg/math/math.go b/pkg/math/math.go index 772d0af2e..ec2742927 100644 --- a/pkg/math/math.go +++ b/pkg/math/math.go @@ -386,7 +386,7 @@ func Log2(x *internal.Decimal) (*internal.Decimal, error) { return &d, err } _, err = apdContext.Quo(&d, &d, &ln2) - return &d, nil + return &d, err } // Log1p returns the natural logarithm of 1 plus its argument x.