You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ cat /tmp/x.go
package main
func f(x int) int {
return x + 1
}
func main() {
var v []int
println("%d\n", f(v[0]))
}
$ go run /tmp/x.go
panic: runtime error: index out of range
goroutine 1 [running]:
main.f(...)
/tmp/x.go:9
main.main()
/tmp/x.go:9 +0x11
exit status 2
At first glance I thought the line number was wrong, since main.f and main.main are not both on line 9.
But in fact the bug is that main.f shows up at all. The index panic happens preparing the argument to f, not in the inlined copy of f. The line number is correct - v[0] is on line 9. What's wrong is that main.f shows up at all. It should not.
@davidlazar, do you think you'll have time to look at this soon? If not, no worries, just reassign it to mdempsky (I would take it, but I'll be away from email).
At first glance I thought the line number was wrong, since main.f and main.main are not both on line 9.
But in fact the bug is that main.f shows up at all. The index panic happens preparing the argument to f, not in the inlined copy of f. The line number is correct - v[0] is on line 9. What's wrong is that main.f shows up at all. It should not.
/cc @davidlazar @aclements
The text was updated successfully, but these errors were encountered: