mirror of
https://github.com/golang/go.git
synced 2025-05-29 11:25:43 +00:00
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: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
ea53e61c6c
commit
b03dce927b
@ -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
|
||||||
}
|
}
|
||||||
|
11
test/fixedbugs/issue18392.go
Normal file
11
test/fixedbugs/issue18392.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// 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"
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user