aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd/internal/gc/subr.go3
-rw-r--r--src/cmd/internal/gc/typecheck.go13
2 files changed, 16 insertions, 0 deletions
diff --git a/src/cmd/internal/gc/subr.go b/src/cmd/internal/gc/subr.go
index f7c0758400..9dc573e795 100644
--- a/src/cmd/internal/gc/subr.go
+++ b/src/cmd/internal/gc/subr.go
@@ -2172,6 +2172,9 @@ out:
// rebuild elided dots
for c := d - 1; c >= 0; c-- {
+ if n.Left.Type != nil && Isptr[n.Left.Type.Etype] != 0 {
+ n.Left.Implicit = 1
+ }
n.Left = Nod(ODOT, n.Left, newname(dotlist[c].field.Sym))
}
diff --git a/src/cmd/internal/gc/typecheck.go b/src/cmd/internal/gc/typecheck.go
index 9fa19300af..1468d5fb45 100644
--- a/src/cmd/internal/gc/typecheck.go
+++ b/src/cmd/internal/gc/typecheck.go
@@ -2433,6 +2433,19 @@ func lookdot(n *Node, t *Type, dostrcmp int) bool {
}
}
+ ll := n.Left
+ for ll.Left != nil {
+ ll = ll.Left
+ }
+ if ll.Implicit != 0 {
+ if Isptr[ll.Type.Etype] != 0 && ll.Type.Sym != nil && ll.Type.Sym.Def != nil && ll.Type.Sym.Def.Op == OTYPE {
+ // It is invalid to automatically dereference a named pointer type when selecting a method.
+ // Make n->left == ll to clarify error message.
+ n.Left = ll
+ return false
+ }
+ }
+
n.Right = methodname(n.Right, n.Left.Type)
n.Xoffset = f2.Width
n.Type = f2.Type