go version)?go version go1.11 linux/amd64
Yes
go env)?Without empty values:
GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/falconandy/go"
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build437619988=/tmp/go-build -gno-record-gcc-switches
https://play.golang.org/p/ydDs-6YdK64
Compiled successfully
cannot use parser literal (type *parser) as type Parser in return argument:
*parser does not implement Parser (wrong type for AddOperator method)
have AddOperator(string, func(Parser))
want AddOperator(string, Parser)
I'm probably missing something but the code linked at the Playground compiles and executes just fine. Can you please provide a reproducer that actually fails with the error in the OP?
Playground works on Go 1.10.3 - so it's fine there
Thanks, I can reproduce the fail now. Seems like a genuine regression to me.
@josharian @mdempsky
Seems like a backport candidate.
@gopherbot please file this for backport against 1.11. This is a regression.
@griesemer please make a cherry-pick CL once your change is merged in master.
Backport issue(s) opened: #27383 (for 1.11).
Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases.
@agnivade feel free to make a backport issue as soon as you want something considered for backport. Anyone can and should do that, and the decision on backporting can be made on that issue.
Roger.
Simpler reproducer, with irrelevant details stripped:
package p
type F = func(T) // compiles if not type alias or moved below T interface
type T interface {
m(F)
}
type t struct{}
func (t) m(F) {}
var _ T = &t{}
Probably a duplicate of #25838. Leaving open for now.
Change https://golang.org/cl/147286 mentions this issue: cmd/compile: reintroduce work-around for cyclic alias declarations
Change https://golang.org/cl/151339 mentions this issue: [release-branch.go1.11] cmd/compile: reintroduce work-around for cyclic alias declarations
Most helpful comment
@josharian @mdempsky
Seems like a backport candidate.