golang/go

runtime: delineate multiple panics by adding newlines between them

Open

#23,097 opened on Dec 12, 2017

View on GitHub
 (5 comments) (0 reactions) (0 assignees)Go (19,008 forks)batch import
NeedsFixhelp wanted

Repository metrics

Stars
 (133,883 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.9.2 linux/amd64

What did you do?

// a.go
package main

func main() {
	var s []int
	var is interface{} = s
	go func() {
		_ = s == nil
	}()
	go func() {
		_ = is == is
	}()
	
	var m map[string]bool = nil
	_ = m["Go"]
	_, _ = m["Go"]
	m, _ = is.(map[string]bool)
	m = is.(map[string]bool)
}

What did you expect to see?

$ go run a.go
panic: interface conversion: interface {} is []int, not map[string]bool

goroutine 1 [running]:
main.main()
	/tmp/a.go:17 +0x15a
panic: runtime error: comparing uncomparable type []int

goroutine 19 [running]:
main.main.func2(0x45b480, 0x4cc2c0)
	/tmp/a.go:10 +0x3a
created by main.main
	/tmp/a.go:9 +0xc9
exit status 2

What did you see instead?

$ go run a.go

panic: interface conversion: interface {} is []int, not map[string]bool
goroutine 1 [running]:
main.main()
	/tmp/a.go:17 +0x15a

panic: runtime error: comparing uncomparable type []int
goroutine 19 [running]:
main.main.func2(0x45b480, 0x4cc2c0)
	/tmp/a.go:10 +0x3a
created by main.main
	/tmp/a.go:9 +0xc9
exit status 2

Contributor guide