From 7e81bcf39fe40e975e2c72375ab28ae9bf272d62 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 3 Mar 2025 12:26:51 -0800 Subject: [PATCH] go/types, types2: remove remaining mentions of core type in error messages The implementatiom still calls coreType in places and refers to "core types" in comments, but user-visible error messages don't know about core types anymore. This brings the user-visible part of the implementation in sync with the spec which doesn't have the notion of core types anymore. For #70128. Change-Id: I14bc6767a83e8f54b10ebe99a7df0b98cd9fca87 Reviewed-on: https://go-review.googlesource.com/c/go/+/654395 Auto-Submit: Robert Griesemer Reviewed-by: Robert Findley LUCI-TryBot-Result: Go LUCI Reviewed-by: Robert Griesemer --- src/cmd/compile/internal/types2/index.go | 2 +- src/cmd/compile/internal/types2/infer.go | 2 +- src/cmd/compile/internal/types2/signature.go | 2 +- src/go/types/index.go | 2 +- src/go/types/infer.go | 2 +- src/go/types/signature.go | 2 +- src/internal/types/testdata/check/typeparams.go | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cmd/compile/internal/types2/index.go b/src/cmd/compile/internal/types2/index.go index d1d7a530b6..451c5e2f9a 100644 --- a/src/cmd/compile/internal/types2/index.go +++ b/src/cmd/compile/internal/types2/index.go @@ -217,7 +217,7 @@ func (check *Checker) sliceExpr(x *operand, e *syntax.SliceExpr) { length := int64(-1) // valid if >= 0 switch u := coreString(x.typ).(type) { case nil: - check.errorf(x, NonSliceableOperand, invalidOp+"cannot slice %s: %s has no core type", x, x.typ) + check.errorf(x, NonSliceableOperand, invalidOp+"cannot slice %s: %s has no common underlying type", x, x.typ) x.mode = invalid return diff --git a/src/cmd/compile/internal/types2/infer.go b/src/cmd/compile/internal/types2/infer.go index 56f0444686..865cabe31c 100644 --- a/src/cmd/compile/internal/types2/infer.go +++ b/src/cmd/compile/internal/types2/infer.go @@ -265,7 +265,7 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeParam, targs []Type, } case single && !core.tilde: if traceInference { - u.tracef("-> set type parameter %s to constraint core type %s", tpar, core.typ) + u.tracef("-> set type parameter %s to constraint's common underlying type %s", tpar, core.typ) } // The corresponding type argument tx is unknown and the core term // describes a single specific type and no tilde. diff --git a/src/cmd/compile/internal/types2/signature.go b/src/cmd/compile/internal/types2/signature.go index 622eb1383d..892fa0e460 100644 --- a/src/cmd/compile/internal/types2/signature.go +++ b/src/cmd/compile/internal/types2/signature.go @@ -45,7 +45,7 @@ func NewSignatureType(recv *Var, recvTypeParams, typeParams []*TypeParam, params } core := coreString(params.At(n - 1).typ) if _, ok := core.(*Slice); !ok && !isString(core) { - panic(fmt.Sprintf("got %s, want variadic parameter with unnamed slice type or string as core type", core.String())) + panic(fmt.Sprintf("got %s, want variadic parameter with unnamed slice type or string as common underlying type", core.String())) } } sig := &Signature{recv: recv, params: params, results: results, variadic: variadic} diff --git a/src/go/types/index.go b/src/go/types/index.go index 1c04f16a97..88c32706ee 100644 --- a/src/go/types/index.go +++ b/src/go/types/index.go @@ -219,7 +219,7 @@ func (check *Checker) sliceExpr(x *operand, e *ast.SliceExpr) { length := int64(-1) // valid if >= 0 switch u := coreString(x.typ).(type) { case nil: - check.errorf(x, NonSliceableOperand, invalidOp+"cannot slice %s: %s has no core type", x, x.typ) + check.errorf(x, NonSliceableOperand, invalidOp+"cannot slice %s: %s has no common underlying type", x, x.typ) x.mode = invalid return diff --git a/src/go/types/infer.go b/src/go/types/infer.go index 873e351732..c04ca98fb5 100644 --- a/src/go/types/infer.go +++ b/src/go/types/infer.go @@ -268,7 +268,7 @@ func (check *Checker) infer(posn positioner, tparams []*TypeParam, targs []Type, } case single && !core.tilde: if traceInference { - u.tracef("-> set type parameter %s to constraint core type %s", tpar, core.typ) + u.tracef("-> set type parameter %s to constraint's common underlying type %s", tpar, core.typ) } // The corresponding type argument tx is unknown and the core term // describes a single specific type and no tilde. diff --git a/src/go/types/signature.go b/src/go/types/signature.go index 365b111939..babb24b0ca 100644 --- a/src/go/types/signature.go +++ b/src/go/types/signature.go @@ -58,7 +58,7 @@ func NewSignatureType(recv *Var, recvTypeParams, typeParams []*TypeParam, params } core := coreString(params.At(n - 1).typ) if _, ok := core.(*Slice); !ok && !isString(core) { - panic(fmt.Sprintf("got %s, want variadic parameter with unnamed slice type or string as core type", core.String())) + panic(fmt.Sprintf("got %s, want variadic parameter with unnamed slice type or string as common underlying type", core.String())) } } sig := &Signature{recv: recv, params: params, results: results, variadic: variadic} diff --git a/src/internal/types/testdata/check/typeparams.go b/src/internal/types/testdata/check/typeparams.go index d4fd35645f..1504442e06 100644 --- a/src/internal/types/testdata/check/typeparams.go +++ b/src/internal/types/testdata/check/typeparams.go @@ -134,11 +134,11 @@ func _[T interface{ ~string }] (x T, i, j, k int) { var _ T = x[i:j:k /* ERROR " type myByte1 []byte type myByte2 []byte func _[T interface{ []byte | myByte1 | myByte2 }] (x T, i, j, k int) { var _ T = x[i:j:k] } -func _[T interface{ []byte | myByte1 | []int }] (x T, i, j, k int) { var _ T = x /* ERROR "no core type" */ [i:j:k] } +func _[T interface{ []byte | myByte1 | []int }] (x T, i, j, k int) { var _ T = x /* ERROR "no common underlying type" */ [i:j:k] } func _[T interface{ []byte | myByte1 | myByte2 | string }] (x T, i, j, k int) { var _ T = x[i:j] } func _[T interface{ []byte | myByte1 | myByte2 | string }] (x T, i, j, k int) { var _ T = x[i:j:k /* ERROR "3-index slice of string" */ ] } -func _[T interface{ []byte | myByte1 | []int | string }] (x T, i, j, k int) { var _ T = x /* ERROR "no core type" */ [i:j] } +func _[T interface{ []byte | myByte1 | []int | string }] (x T, i, j, k int) { var _ T = x /* ERROR "no common underlying type" */ [i:j] } // len/cap built-ins -- 2.50.0