mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.typeparams] cmd/compile/internal/types: adjust some error messages to match the compiler
Change-Id: I04bd7b294de4ed0fb01bc0609e09debea2d797bd Reviewed-on: https://go-review.googlesource.com/c/go/+/274974 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
6b4da14dd3
commit
07d32c8183
3 changed files with 11 additions and 3 deletions
|
|
@ -1867,8 +1867,12 @@ func (check *Checker) typeAssertion(pos syntax.Pos, x *operand, xtyp *Interface,
|
|||
} else {
|
||||
msg = "missing method " + method.name
|
||||
}
|
||||
if check.conf.CompilerErrorMessages {
|
||||
check.errorf(pos, "impossible type assertion: %s (%s)", x, msg)
|
||||
} else {
|
||||
check.errorf(pos, "%s cannot have dynamic type %s (%s)", x, T, msg)
|
||||
}
|
||||
}
|
||||
|
||||
// expr typechecks expression e and initializes x with the expression value.
|
||||
// The result must be a single value.
|
||||
|
|
|
|||
|
|
@ -886,7 +886,7 @@ func rangeKeyVal(typ Type, wantKey, wantVal bool) (Type, Type, string) {
|
|||
case *Chan:
|
||||
var msg string
|
||||
if typ.dir == SendOnly {
|
||||
msg = "send-only channel"
|
||||
msg = "receive from send-only channel"
|
||||
}
|
||||
return typ.elem, Typ[Invalid], msg
|
||||
case *Sum:
|
||||
|
|
|
|||
|
|
@ -806,7 +806,11 @@ func (check *Checker) interfaceType(ityp *Interface, iface *syntax.InterfaceType
|
|||
// of a type list (f.Name.Value == "type").
|
||||
name := f.Name.Value
|
||||
if name == "_" {
|
||||
if check.conf.CompilerErrorMessages {
|
||||
check.errorf(f.Name, "methods must have a unique non-blank name")
|
||||
} else {
|
||||
check.errorf(f.Name, "invalid method name _")
|
||||
}
|
||||
continue // ignore
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue