Skip to content

cmd/compile: ambiguous interface conversion panic message #21156

@rogpeppe

Description

@rogpeppe

go version devel +286599f Tue Jul 11 18:32:56 2017 +0000 linux/amd64

When a dynamic type coercion between two types with the same
package identifier and type name, the panic message is confusing
because it does not include the package path.

For example, when running:

package main

import (
	cookiejar2 "github.com/juju/persistent-cookiejar"
	"net/http"
	cookiejar1 "net/http/cookiejar"
)

func main() {
	jar, _ := cookiejar1.New(nil)
	j := http.CookieJar(jar)
	_ = j.(*cookiejar2.Jar)
}

I see:

panic: interface conversion: http.CookieJar is *cookiejar.Jar, not *cookiejar.Jar

goroutine 1 [running]:
main.main()
	/home/rog/src/tst.go:12 +0xff

I would expect to see something like this instead:

panic: interface conversion: http.CookieJar is *"net/http/cookiejar".Jar, not *"github.com/juju/persistent-cookiejar".Jar

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions