Skip to content

Commit 7e81bcf

Browse files
griesemergopherbot
authored andcommitted
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 <[email protected]> Reviewed-by: Robert Findley <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Robert Griesemer <[email protected]>
1 parent 0a0e6af commit 7e81bcf

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

src/cmd/compile/internal/types2/index.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func (check *Checker) sliceExpr(x *operand, e *syntax.SliceExpr) {
217217
length := int64(-1) // valid if >= 0
218218
switch u := coreString(x.typ).(type) {
219219
case nil:
220-
check.errorf(x, NonSliceableOperand, invalidOp+"cannot slice %s: %s has no core type", x, x.typ)
220+
check.errorf(x, NonSliceableOperand, invalidOp+"cannot slice %s: %s has no common underlying type", x, x.typ)
221221
x.mode = invalid
222222
return
223223

src/cmd/compile/internal/types2/infer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeParam, targs []Type,
265265
}
266266
case single && !core.tilde:
267267
if traceInference {
268-
u.tracef("-> set type parameter %s to constraint core type %s", tpar, core.typ)
268+
u.tracef("-> set type parameter %s to constraint's common underlying type %s", tpar, core.typ)
269269
}
270270
// The corresponding type argument tx is unknown and the core term
271271
// describes a single specific type and no tilde.

src/cmd/compile/internal/types2/signature.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func NewSignatureType(recv *Var, recvTypeParams, typeParams []*TypeParam, params
4545
}
4646
core := coreString(params.At(n - 1).typ)
4747
if _, ok := core.(*Slice); !ok && !isString(core) {
48-
panic(fmt.Sprintf("got %s, want variadic parameter with unnamed slice type or string as core type", core.String()))
48+
panic(fmt.Sprintf("got %s, want variadic parameter with unnamed slice type or string as common underlying type", core.String()))
4949
}
5050
}
5151
sig := &Signature{recv: recv, params: params, results: results, variadic: variadic}

src/go/types/index.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ func (check *Checker) sliceExpr(x *operand, e *ast.SliceExpr) {
219219
length := int64(-1) // valid if >= 0
220220
switch u := coreString(x.typ).(type) {
221221
case nil:
222-
check.errorf(x, NonSliceableOperand, invalidOp+"cannot slice %s: %s has no core type", x, x.typ)
222+
check.errorf(x, NonSliceableOperand, invalidOp+"cannot slice %s: %s has no common underlying type", x, x.typ)
223223
x.mode = invalid
224224
return
225225

src/go/types/infer.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/go/types/signature.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func NewSignatureType(recv *Var, recvTypeParams, typeParams []*TypeParam, params
5858
}
5959
core := coreString(params.At(n - 1).typ)
6060
if _, ok := core.(*Slice); !ok && !isString(core) {
61-
panic(fmt.Sprintf("got %s, want variadic parameter with unnamed slice type or string as core type", core.String()))
61+
panic(fmt.Sprintf("got %s, want variadic parameter with unnamed slice type or string as common underlying type", core.String()))
6262
}
6363
}
6464
sig := &Signature{recv: recv, params: params, results: results, variadic: variadic}

src/internal/types/testdata/check/typeparams.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ func _[T interface{ ~string }] (x T, i, j, k int) { var _ T = x[i:j:k /* ERROR "
134134
type myByte1 []byte
135135
type myByte2 []byte
136136
func _[T interface{ []byte | myByte1 | myByte2 }] (x T, i, j, k int) { var _ T = x[i:j:k] }
137-
func _[T interface{ []byte | myByte1 | []int }] (x T, i, j, k int) { var _ T = x /* ERROR "no core type" */ [i:j:k] }
137+
func _[T interface{ []byte | myByte1 | []int }] (x T, i, j, k int) { var _ T = x /* ERROR "no common underlying type" */ [i:j:k] }
138138

139139
func _[T interface{ []byte | myByte1 | myByte2 | string }] (x T, i, j, k int) { var _ T = x[i:j] }
140140
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" */ ] }
141-
func _[T interface{ []byte | myByte1 | []int | string }] (x T, i, j, k int) { var _ T = x /* ERROR "no core type" */ [i:j] }
141+
func _[T interface{ []byte | myByte1 | []int | string }] (x T, i, j, k int) { var _ T = x /* ERROR "no common underlying type" */ [i:j] }
142142

143143
// len/cap built-ins
144144

0 commit comments

Comments
 (0)