diff --git a/cue/ast/astutil/sanitize.go b/cue/ast/astutil/sanitize.go index 98f9fc820..95abdda98 100644 --- a/cue/ast/astutil/sanitize.go +++ b/cue/ast/astutil/sanitize.go @@ -347,7 +347,7 @@ func (z *sanitizer) uniqueName(base string, hidden bool) string { const mask = 0xff_ffff_ffff_ffff // max bits; stay clear of int64 overflow const shift = 4 // rate of growth - for n := int64(0x10); ; n = int64(mask&((n< 1+index(f.size) { + if x < 1 || x > 1+f.size { panic("illegal Pos value") } return int(x - 1) @@ -436,7 +436,7 @@ func searchLineInfos(a []lineInfo, x int) int { func (f *File) unpack(offset index, adjusted bool) (filename string, line, column int) { filename = f.name if i := searchInts(f.lines, offset); i >= 0 { - line, column = int(i+1), int(offset-f.lines[i]+1) + line, column = i+1, int(offset-f.lines[i]+1) } if adjusted && len(f.infos) > 0 { // almost no files have extra line infos diff --git a/cue/types.go b/cue/types.go index 185abf8fc..bcd6e023d 100644 --- a/cue/types.go +++ b/cue/types.go @@ -1095,7 +1095,7 @@ func (v Value) checkKind(ctx *adt.OpContext, want adt.Kind) *adt.Bottom { func makeInt(v Value, x int64) Value { n := &adt.Num{K: adt.IntKind} - n.X.SetInt64(int64(x)) + n.X.SetInt64(x) return remakeFinal(v, n) } diff --git a/cue/types_test.go b/cue/types_test.go index 69b2f9eba..c682d42fe 100644 --- a/cue/types_test.go +++ b/cue/types_test.go @@ -421,7 +421,7 @@ func TestInt(t *testing.T) { vu, err := n.Uint64() checkErr(t, err, tc.errU, "Uint64") - if vu != uint64(tc.uint) { + if vu != tc.uint { t.Errorf("Uint64: got %v; want %v", vu, tc.uint) } }) diff --git a/encoding/openapi/build.go b/encoding/openapi/build.go index 8074dbc8a..89ee9cbaf 100644 --- a/encoding/openapi/build.go +++ b/encoding/openapi/build.go @@ -257,7 +257,7 @@ func (b *builder) fillSchema(v cue.Value) *ast.StructLit { } schema := b.finish() - s := (*ast.StructLit)(schema) + s := schema simplify(b, s) @@ -529,7 +529,7 @@ func (b *builder) disjunction(a []cue.Value, f typeFunc) { c := newOASBuilder(b) c.value(v, f) t := c.finish() - schemas[i] = (*ast.StructLit)(t) + schemas[i] = t if len(t.Elts) == 0 { if c.typ == "" { return @@ -1207,7 +1207,7 @@ func (b *builder) add(t *ast.StructLit) { func (b *builder) addConjunct(f func(*builder)) { c := newOASBuilder(b) f(c) - b.add((*ast.StructLit)(c.finish())) + b.add(c.finish()) } func (b *builder) addRef(v cue.Value, inst cue.Value, ref cue.Path) { diff --git a/internal/core/compile/label.go b/internal/core/compile/label.go index 24bed7d4b..2d0daf573 100644 --- a/internal/core/compile/label.go +++ b/internal/core/compile/label.go @@ -44,7 +44,7 @@ func (c *compiler) label(n ast.Node) adt.Feature { return adt.InvalidLabel } - i := int64(index.StringToIndex(norm.NFC.String(s))) + i := index.StringToIndex(norm.NFC.String(s)) f, err := adt.MakeLabel(n, i, adt.StringLabel) if err != nil { c.errf(n, msg, err) diff --git a/internal/core/convert/go.go b/internal/core/convert/go.go index 30282fb62..72e8c36f9 100644 --- a/internal/core/convert/go.go +++ b/internal/core/convert/go.go @@ -344,7 +344,7 @@ func (c *goConverter) convertRec(nilIsTop bool, x interface{}) (result adt.Value case int32: return c.toInt(int64(v)) case int64: - return c.toInt(int64(v)) + return c.toInt(v) case uint: return c.toUint(uint64(v)) case uint8: @@ -354,7 +354,7 @@ func (c *goConverter) convertRec(nilIsTop bool, x interface{}) (result adt.Value case uint32: return c.toUint(uint64(v)) case uint64: - return c.toUint(uint64(v)) + return c.toUint(v) case uintptr: return c.toUint(uint64(v)) case float64: diff --git a/internal/core/export/export.go b/internal/core/export/export.go index 331b39f38..2d5eda2fd 100644 --- a/internal/core/export/export.go +++ b/internal/core/export/export.go @@ -686,7 +686,7 @@ func findUnique(set featureSet, base string) (f adt.Feature, name string) { const mask = 0xff_ffff_ffff_ffff // max bits; stay clear of int64 overflow const shift = 4 // rate of growth digits := 1 - for n := int64(0x10); ; n = int64(mask&((n<