From e190842fd587d8a296c7e77e3cfa3cf089bcfb77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Wed, 3 Dec 2025 11:46:52 +0000 Subject: [PATCH] internal: remove unnecessary Pos methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit adt.BuiltinValidator had a Pos method which was never used. pkg.CallCtxt had a Pos method which was used within the same package, so inline the three uses instead, given its simplicity. Signed-off-by: Daniel Martí Change-Id: I23d1ed9e4daf2a738ebe31d55e8e87ce52e40aed Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1227395 Reviewed-by: Matthew Sackman TryBot-Result: CUEcueckoo --- internal/core/adt/expr.go | 4 ---- internal/pkg/builtin.go | 4 ++-- internal/pkg/context.go | 5 ----- internal/pkg/errors.go | 2 +- 4 files changed, 3 insertions(+), 12 deletions(-) diff --git a/internal/core/adt/expr.go b/internal/core/adt/expr.go index 0a5002859..a6c1cd4a2 100644 --- a/internal/core/adt/expr.go +++ b/internal/core/adt/expr.go @@ -1711,10 +1711,6 @@ func (x *BuiltinValidator) Source() ast.Node { return x.Src.Source() } -func (x *BuiltinValidator) Pos() token.Pos { - return Pos(x) -} - func (x *BuiltinValidator) Kind() Kind { return x.Builtin.Params[0].Kind() } diff --git a/internal/pkg/builtin.go b/internal/pkg/builtin.go index 1f285f1c1..baa3243dd 100644 --- a/internal/pkg/builtin.go +++ b/internal/pkg/builtin.go @@ -241,12 +241,12 @@ func processErr(call *CallCtxt, errVal interface{}, ret adt.Expr) adt.Expr { case string, fmt.Stringer: // A string or a stringer likely used as a panic value. ret = wrapCallErr(call, &adt.Bottom{ - Err: errors.Newf(call.Pos(), "%s", err), + Err: errors.Newf(call.ctx.Pos(), "%s", err), }) default: // Some other value used when panicking; likely a bug. ret = wrapCallErr(call, &adt.Bottom{ - Err: errors.Newf(call.Pos(), "BUG: non-stringifiable %T", err), + Err: errors.Newf(call.ctx.Pos(), "BUG: non-stringifiable %T", err), }) } return ret diff --git a/internal/pkg/context.go b/internal/pkg/context.go index ca7f61eac..07be918b2 100644 --- a/internal/pkg/context.go +++ b/internal/pkg/context.go @@ -22,7 +22,6 @@ import ( "github.com/cockroachdb/apd/v3" "cuelang.org/go/cue" - "cuelang.org/go/cue/token" "cuelang.org/go/internal/core/adt" "cuelang.org/go/internal/value" ) @@ -38,10 +37,6 @@ type CallCtxt struct { args []adt.Value } -func (c *CallCtxt) Pos() token.Pos { - return c.ctx.Pos() -} - func (c *CallCtxt) Name() string { return c.builtin.name(c.ctx) } diff --git a/internal/pkg/errors.go b/internal/pkg/errors.go index d374fb9f5..4c06c2ae5 100644 --- a/internal/pkg/errors.go +++ b/internal/pkg/errors.go @@ -48,7 +48,7 @@ func (c *CallCtxt) errf(underlying error, format string, args ...interface{}) { case error: errs = errors.Promote(x, "") } - vErr := c.ctx.NewPosf(c.Pos(), format, args...) + vErr := c.ctx.NewPosf(c.ctx.Pos(), format, args...) c.Err = &callError{&adt.Bottom{Code: code, Err: errors.Wrap(vErr, errs)}} } -- 2.51.2