]> Cypherpunks repositories - gostls13.git/commitdiff
encoding/gob: improve interface assignment error message
authorKelsey Hightower <kelsey.hightower@gmail.com>
Wed, 5 Mar 2014 19:52:18 +0000 (06:52 +1100)
committerRob Pike <r@golang.org>
Wed, 5 Mar 2014 19:52:18 +0000 (06:52 +1100)
During the glob decoding process interface values are set to concrete
values after a test for assignability. If the assignability test fails
a slightly vague error message is produced. While technically accurate
the error message does not clearly describe the problem.

Rewrite the error message to include the usage of the word assignable,
which makes it clear the concrete value type is not assignable to the
interface value type.

Fixes #6467.

LGTM=r
R=golang-codereviews, rsc, r
CC=golang-codereviews
https://golang.org/cl/71590043

src/pkg/encoding/gob/decode.go

index aa186a582e87a906f6101cb294e32c246b244203..d8513148ec2d5bbe9b34c468abf1f718b4f7b1b1 100644 (file)
@@ -685,7 +685,7 @@ func (dec *Decoder) ignoreSlice(state *decoderState, elemOp decOp) {
 // but first it checks that the assignment will succeed.
 func setInterfaceValue(ivalue reflect.Value, value reflect.Value) {
        if !value.Type().AssignableTo(ivalue.Type()) {
-               errorf("cannot assign value of type %s to %s", value.Type(), ivalue.Type())
+               errorf("%s is not assignable to type %s", value.Type(), ivalue.Type())
        }
        ivalue.Set(value)
 }