diff --git a/cmd/cue/cmd/common.go b/cmd/cue/cmd/common.go index 302e7e2f1a8..f361704aafc 100644 --- a/cmd/cue/cmd/common.go +++ b/cmd/cue/cmd/common.go @@ -36,7 +36,6 @@ import ( "cuelang.org/go/internal/core/adt" "cuelang.org/go/internal/encoding" "cuelang.org/go/internal/filetypes" - "cuelang.org/go/internal/value" ) var requestedVersion = os.Getenv("CUE_SYNTAX_OVERRIDE") @@ -810,10 +809,11 @@ func buildTools(cmd *Command, args []string) (*cue.Instance, error) { inst = cue.Merge(insts...) } - r := value.ConvertToRuntime(inst.Value().Context()) + ctx := inst.Value().Context() for _, b := range binst { for _, i := range b.Imports { - if _, err := r.Build(i); err != nil { + val := ctx.BuildInstance(i) + if err := val.Err(); err != nil { return nil, err } } diff --git a/cmd/cue/cmd/flags.go b/cmd/cue/cmd/flags.go index 0e9e1c4cfab..91d5db73f8e 100644 --- a/cmd/cue/cmd/flags.go +++ b/cmd/cue/cmd/flags.go @@ -116,11 +116,6 @@ func addInjectionFlags(f *pflag.FlagSet, auto, hidden bool) { type flagName string -type unaddedFlagUse struct { - cmd string - flag flagName -} - // ensureAdded detects if a flag is being used without it first being // added to the flagSet. Because flagNames are global, it is quite // easy to accidentally use a flag in a command without adding it to diff --git a/cmd/cue/cmd/get_go.go b/cmd/cue/cmd/get_go.go index 9675ede0731..bee1b62fd8b 100644 --- a/cmd/cue/cmd/get_go.go +++ b/cmd/cue/cmd/get_go.go @@ -301,7 +301,9 @@ func typeSignature(params, results []types.Type) *types.Signature { for i, result := range results { resultVars[i] = types.NewParam(token.NoPos, nil, "", result) } - return types.NewSignature( + return types.NewSignatureType( + nil, + nil, nil, types.NewTuple(paramVars...), types.NewTuple(resultVars...), diff --git a/encoding/gocode/generator.go b/encoding/gocode/generator.go index 6c4e8befd1a..59e63d1e926 100644 --- a/encoding/gocode/generator.go +++ b/encoding/gocode/generator.go @@ -27,7 +27,6 @@ import ( "cuelang.org/go/cue" "cuelang.org/go/cue/errors" - "cuelang.org/go/internal/value" ) // Config defines options for generation Go code. @@ -154,7 +153,7 @@ func Generate(pkgPath string, inst cue.InstanceOrValue, c *Config) (b []byte, er g.decl(iter.Label(), iter.Value()) } - r := value.ConvertToRuntime(val.Context()) + r := (*cue.Runtime)(val.Context()) b, err = r.Marshal(&val) g.addErr(err) diff --git a/encoding/gocode/gocodec/codec.go b/encoding/gocode/gocodec/codec.go index b40223c9940..d5b4e5809eb 100644 --- a/encoding/gocode/gocodec/codec.go +++ b/encoding/gocode/gocodec/codec.go @@ -95,7 +95,7 @@ func (c *Codec) Encode(v cue.Value, x interface{}) error { return v.Decode(x) } -var defaultCodec = New(value.ConvertToRuntime(cuecontext.New()), nil) +var defaultCodec = New(cuecontext.New(), nil) // Validate calls Validate on a default Codec for the type of x. func Validate(x interface{}) error { diff --git a/internal/ci/checks/commit.go b/internal/ci/checks/commit.go index 86c5b963d2c..3221a017ccf 100644 --- a/internal/ci/checks/commit.go +++ b/internal/ci/checks/commit.go @@ -51,7 +51,7 @@ func checkCommit(dir string) error { // line because each commit must be signed-off. lines := strings.Split(body, "\n") if len(lines) > 1 && lines[1] != "" { - return fmt.Errorf("The second line of a commit message must be blank") + return fmt.Errorf("the second line of a commit message must be blank") } // All authors, including co-authors, must have a signed-off trailer by email. diff --git a/internal/envflag/flag.go b/internal/envflag/flag.go index 4c640ffafd2..085aa7c8c38 100644 --- a/internal/envflag/flag.go +++ b/internal/envflag/flag.go @@ -67,7 +67,7 @@ func Parse[T any](flags *T, env string) error { v, err := strconv.ParseBool(valueStr) if err != nil { // Invalid format, return an error immediately. - return invalidError{ + return errInvalid{ fmt.Errorf("invalid bool value for %s: %v", name, err), } } @@ -85,11 +85,11 @@ func Parse[T any](flags *T, env string) error { return errors.Join(errs...) } -// An InvalidError indicates a malformed input string. -var InvalidError = errors.New("invalid value") +// An ErrInvalid indicates a malformed input string. +var ErrInvalid = errors.New("invalid value") -type invalidError struct{ error } +type errInvalid struct{ error } -func (invalidError) Is(err error) bool { - return err == InvalidError +func (errInvalid) Is(err error) bool { + return err == ErrInvalid } diff --git a/internal/envflag/flag_test.go b/internal/envflag/flag_test.go index 378a980a086..07d4ac3e1ae 100644 --- a/internal/envflag/flag_test.go +++ b/internal/envflag/flag_test.go @@ -36,7 +36,7 @@ func invalid[T comparable](want T) func(t *testing.T) { return func(t *testing.T) { var x T err := Init(&x, "TEST_VAR") - qt.Assert(t, qt.ErrorIs(err, InvalidError)) + qt.Assert(t, qt.ErrorIs(err, ErrInvalid)) qt.Assert(t, qt.Equals(x, want)) } } diff --git a/internal/pkg/types.go b/internal/pkg/types.go index e3422c38c5b..e7e3bfb6254 100644 --- a/internal/pkg/types.go +++ b/internal/pkg/types.go @@ -74,10 +74,7 @@ func (s *Struct) IsOpen() bool { } // The equivalent code for the old implementation. ot := s.node.OptionalTypes() - if ot&^adt.HasDynamic != 0 { - return true - } - return false + return ot&^adt.HasDynamic != 0 } // A ValidationError indicates an error that is only valid if a builtin is used diff --git a/internal/value/value.go b/internal/value/value.go index 7f5e0bf627d..65c1b14345e 100644 --- a/internal/value/value.go +++ b/internal/value/value.go @@ -27,10 +27,6 @@ import ( "cuelang.org/go/internal/types" ) -func ConvertToRuntime(c *cue.Context) *cue.Runtime { - return (*cue.Runtime)(c) -} - func ConvertToContext[Ctx *cue.Runtime | *cue.Context](ctx Ctx) *cue.Context { if ctx, ok := any(ctx).(*cue.Runtime); ok { (*runtime.Runtime)(ctx).Init()