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
1. What is a short input program that triggers the error?
Here are two examples:
$ cat p1.go
package p1
type O map[string]map[string]string
func (opts O) RemoveOption(sect, opt string) bool {
if _, ok := opts[sect]; !ok {
return false
}
_, ok := opts[sect][opt]
delete(opts[sect], opt)
return ok
}
$ cat p2.go
package p2
import "./p1"
func NewO() p1.O { return nil }
$ cat main.go
package main
import "./p2"
func main() {
p2.NewO().RemoveOption("hello", "world")
}
$ cat q1.go
package q1
func Deref(typ interface{}) interface{} {
if typ, ok := typ.(*int); ok {
return *typ
}
return typ
}
$ cat q2.go
package main
import "./q1"
func main() {
x := 1
y := q1.Deref(&x)
if y != 1 {
panic("y != 1")
}
}
2. What is the full compiler output?
$ go tool 8g -I. p1.go
$ go tool 8g -I. p2.go
$ go tool 8g -I. main.go
main.go:3: p1.ok redeclared in this block
previous declaration at main.go:3
go tool 8g: exit status 1
$ go tool 8g -I. q1.go
$ go tool 8g -I. q2.go
q2.go:3: invalid type assertion: q1.typ.(*int) (non-interface type *int on left)
q2.go:7: tempname called with nil type
q2.go:7: internal compiler error: typename <T>
go tool 8g: exit status 1
3. What version of the compiler are you using? (Run it with the -V flag.)
8g version devel +5bc48b616305 Thu Nov 01 13:04:08 2012 +1100
Attachments:
The text was updated successfully, but these errors were encountered: