1
0
mirror of https://github.com/golang/go synced 2024-11-25 09:27:57 -07:00
go/test/fixedbugs/issue23734.go
Keith Randall ed15e82413 runtime: panic on uncomparable map key, even if map is empty
Reorg map flags a bit so we don't need any extra space for the extra flag.

Fixes #23734

Change-Id: I436812156240ae90de53d0943fe1aabf3ea37417
Reviewed-on: https://go-review.googlesource.com/c/155918
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-12-29 01:00:54 +00:00

33 lines
471 B
Go

// run
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
func main() {
m := map[interface{}]int{}
k := []int{}
mustPanic(func() {
_ = m[k]
})
mustPanic(func() {
_, _ = m[k]
})
mustPanic(func() {
delete(m, k)
})
}
func mustPanic(f func()) {
defer func() {
r := recover()
if r == nil {
panic("didn't panic")
}
}()
f()
}