Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: method expressions of implicitly defined methods fail #29389

Closed
randall77 opened this issue Dec 21, 2018 · 3 comments
Closed

cmd/compile: method expressions of implicitly defined methods fail #29389

randall77 opened this issue Dec 21, 2018 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@randall77
Copy link
Contributor

package main

import "io"

func main() {
	err := io.EOF
	_ = err.Error
}

This fails on tip with

# command-line-arguments
panic: runtime error: index out of range

goroutine 52 [running]:
cmd/compile/internal/gc.(*state).peekPos(...)
	/usr/local/google/home/khr/sandbox/issue29007/src/cmd/compile/internal/gc/ssa.go:484
cmd/compile/internal/gc.(*state).pushLine(0xc00054c4e0, 0x0)
	/usr/local/google/home/khr/sandbox/issue29007/src/cmd/compile/internal/gc/ssa.go:466 +0x19c
cmd/compile/internal/gc.buildssa(0xc0000cc420, 0x3, 0x0)
	/usr/local/google/home/khr/sandbox/issue29007/src/cmd/compile/internal/gc/ssa.go:130 +0xe7
cmd/compile/internal/gc.compileSSA(0xc0000cc420, 0x3)
	/usr/local/google/home/khr/sandbox/issue29007/src/cmd/compile/internal/gc/pgen.go:280 +0x4d
cmd/compile/internal/gc.compileFunctions.func2(0xc000538c00, 0xc00053a230, 0x3)
	/usr/local/google/home/khr/sandbox/issue29007/src/cmd/compile/internal/gc/pgen.go:345 +0x49
created by cmd/compile/internal/gc.compileFunctions
	/usr/local/google/home/khr/sandbox/issue29007/src/cmd/compile/internal/gc/pgen.go:343 +0x129

The problem is that it's making a function from a method (the err.Error part), but it can't find the original line number of the method declaration. It is the implicit declaration of Error for the built-in error type, which doesn't have a line number.
We need a backstop line number for cases where the method declaration is implicit.

@bcmills bcmills added NeedsFix The path to resolution is known, but the work has not been done. release-blocker labels Dec 21, 2018
@bcmills bcmills added this to the Go1.12 milestone Dec 21, 2018
@mark-rushakoff
Copy link
Contributor

Related to #29304?

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/155639 mentions this issue: cmd/compile: fix line number for implicitly declared method expressions

@randall77
Copy link
Contributor Author

@mark-rushakoff I don't think they are directly related. Both have to do with error.Error, but as far as I can tell in unrelated ways.

@golang golang locked and limited conversation to collaborators Dec 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

4 participants