Commit b03dce92 authored by Emmanuel Odeke's avatar Emmanuel Odeke Committed by Matthew Dempsky

cmd/compile: avoid n.Right nil dereference on non-existent interface methods

Fixes #18392.

Avoid nil dereferencing n.Right when dealing with non-existent
self referenced interface methods e.g.
type A interface{
  Fn(A.Fn)
}

Instead, infer the symbol name from n.Sym itself.

Change-Id: I60d5f8988e7318693e5c8da031285d8d7347b771
Reviewed-on: https://go-review.googlesource.com/34817
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
parent ea53e61c
...@@ -859,7 +859,7 @@ OpSwitch: ...@@ -859,7 +859,7 @@ OpSwitch:
} }
if n.Type.Etype != TFUNC || !n.IsMethod() { if n.Type.Etype != TFUNC || !n.IsMethod() {
yyerror("type %v has no method %S", n.Left.Type, n.Right.Sym) yyerror("type %v has no method %S", n.Left.Type, n.Sym)
n.Type = nil n.Type = nil
return n return n
} }
......
// errorcheck
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package p
type A interface {
Fn(A.Fn) // ERROR "type A has no method A.Fn"
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment