mirror of
https://github.com/golang/go
synced 2024-11-15 00:20:30 -07:00
go/types, types2: better error message when selecting on a built-in
Fixes #43285. Change-Id: Iddadf76e2dc10fcf77f588c865a68125ebeda290 Reviewed-on: https://go-review.googlesource.com/c/go/+/623756 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
d72b5bc3d7
commit
6f59c11155
@ -774,7 +774,7 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, def *TypeName
|
||||
goto Error
|
||||
}
|
||||
case builtin:
|
||||
check.errorf(e.Pos(), UncalledBuiltin, "cannot select on %s", x)
|
||||
check.errorf(e.Pos(), UncalledBuiltin, "invalid use of %s in selector expression", x)
|
||||
goto Error
|
||||
case invalid:
|
||||
goto Error
|
||||
|
@ -777,7 +777,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr, def *TypeName, w
|
||||
}
|
||||
case builtin:
|
||||
// types2 uses the position of '.' for the error
|
||||
check.errorf(e.Sel, UncalledBuiltin, "cannot select on %s", x)
|
||||
check.errorf(e.Sel, UncalledBuiltin, "invalid use of %s in selector expression", x)
|
||||
goto Error
|
||||
case invalid:
|
||||
goto Error
|
||||
|
@ -5,9 +5,9 @@
|
||||
package p
|
||||
|
||||
func _() {
|
||||
len.Println /* ERROR "cannot select on len" */
|
||||
len.Println /* ERROR "cannot select on len" */ ()
|
||||
_ = len.Println /* ERROR "cannot select on len" */
|
||||
len.Println /* ERROR "invalid use of len (built-in) in selector expression" */
|
||||
len.Println /* ERROR "invalid use of len (built-in) in selector expression" */ ()
|
||||
_ = len.Println /* ERROR "invalid use of len (built-in) in selector expression" */
|
||||
_ = len /* ERROR "cannot index len" */ [0]
|
||||
_ = *len /* ERROR "cannot indirect len" */
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user