aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/typecheck/expr.go
diff options
context:
space:
mode:
authorDan Scales <danscales@google.com>2021-03-24 14:50:02 -0700
committerDan Scales <danscales@google.com>2021-03-25 23:23:10 +0000
commitb587b050ca55661120912b5a1d6071a1922ad0ea (patch)
treebeec6285bd589315d1e82755b8bd5472c4c84371 /src/cmd/compile/internal/typecheck/expr.go
parent374b1904750931ed09d342e3c4c6e01fdb2802aa (diff)
downloadgo-b587b050ca55661120912b5a1d6071a1922ad0ea.tar.gz
go-b587b050ca55661120912b5a1d6071a1922ad0ea.zip
cmd/compile: add transform functions for OXDOT and builtins
Pull out the tranformation part of the typechecking functions for: - selector expressions (OXDOT) - calls to builtin functions (which go through the typechecker loop twice, once for the call and once for each different kind of builtin). Some of the transformation functions create new nodes that should have the same type as the original node. For consistency, now each of the transformation functions requires that the node passed in has its type and typecheck flag set. If the transformation function replaces or adds new nodes, it will set the type and typecheck flag for those new nodes. As usual, passes all the gotests, even with -G=3 enabled. Change-Id: Ic48b0ce5f58425f4a358afa78315bfc7c28066c4 Reviewed-on: https://go-review.googlesource.com/c/go/+/304729 Trust: Dan Scales <danscales@google.com> Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/expr.go')
-rw-r--r--src/cmd/compile/internal/typecheck/expr.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/cmd/compile/internal/typecheck/expr.go b/src/cmd/compile/internal/typecheck/expr.go
index 7ab1670a45..24d141e8a2 100644
--- a/src/cmd/compile/internal/typecheck/expr.go
+++ b/src/cmd/compile/internal/typecheck/expr.go
@@ -366,9 +366,9 @@ func tcCompLit(n *ir.CompLitExpr) (res ir.Node) {
}
l := l.(*ir.StructKeyExpr)
- f := lookdot1(nil, l.Field, t, t.Fields(), 0)
+ f := Lookdot1(nil, l.Field, t, t.Fields(), 0)
if f == nil {
- if ci := lookdot1(nil, l.Field, t, t.Fields(), 2); ci != nil { // Case-insensitive lookup.
+ if ci := Lookdot1(nil, l.Field, t, t.Fields(), 2); ci != nil { // Case-insensitive lookup.
if visible(ci.Sym) {
base.Errorf("unknown field '%v' in struct literal of type %v (but does have %v)", l.Field, t, ci.Sym)
} else if nonexported(l.Field) && l.Field.Name == ci.Sym.Name { // Ensure exactness before the suggestion.
@@ -496,7 +496,7 @@ func tcDot(n *ir.SelectorExpr, top int) ir.Node {
return n
}
- if lookdot(n, t, 0) == nil {
+ if Lookdot(n, t, 0) == nil {
// Legitimate field or method lookup failed, try to explain the error
switch {
case t.IsEmptyInterface():
@@ -506,12 +506,12 @@ func tcDot(n *ir.SelectorExpr, top int) ir.Node {
// Pointer to interface is almost always a mistake.
base.Errorf("%v undefined (type %v is pointer to interface, not interface)", n, n.X.Type())
- case lookdot(n, t, 1) != nil:
+ case Lookdot(n, t, 1) != nil:
// Field or method matches by name, but it is not exported.
base.Errorf("%v undefined (cannot refer to unexported field or method %v)", n, n.Sel)
default:
- if mt := lookdot(n, t, 2); mt != nil && visible(mt.Sym) { // Case-insensitive lookup.
+ if mt := Lookdot(n, t, 2); mt != nil && visible(mt.Sym) { // Case-insensitive lookup.
base.Errorf("%v undefined (type %v has no field or method %v, but does have %v)", n, n.X.Type(), n.Sel, mt.Sym)
} else {
base.Errorf("%v undefined (type %v has no field or method %v)", n, n.X.Type(), n.Sel)