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

Comments

@randall77
Copy link
Contributor

@randall77 randall77 commented Dec 21, 2018

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 this to the Go1.12 milestone Dec 21, 2018
@mark-rushakoff

This comment has been minimized.

Copy link
Contributor

@mark-rushakoff mark-rushakoff commented Dec 21, 2018

Related to #29304?

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Dec 21, 2018

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

@randall77

This comment has been minimized.

Copy link
Contributor Author

@randall77 randall77 commented Dec 22, 2018

@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.

@gopherbot gopherbot closed this in debca77 Dec 22, 2018
@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.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.