commit | c884f6594a594d2d18c4d21106592bd3cdfcbe9b | [log] [tgz] |
---|---|---|
author | Brad Fitzpatrick <bradfitz@golang.org> | Thu Apr 28 22:04:30 2016 -0500 |
committer | Brad Fitzpatrick <bradfitz@golang.org> | Fri Apr 29 03:20:51 2016 +0000 |
tree | 7e6127e3dae428501da925cac185aebe8a623fa0 | |
parent | 694846a548f23cebb9b913999fa4fa6756e2c545 [diff] [blame] |
context: produce a nicer panic message for a nil WithValue key Change-Id: I2e8ae403622ba7131cadaba506100d79613183f1 Reviewed-on: https://go-review.googlesource.com/22601 Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Andrew Gerrand <adg@golang.org>
diff --git a/src/context/context.go b/src/context/context.go index da294b1..5184b94 100644 --- a/src/context/context.go +++ b/src/context/context.go
@@ -428,6 +428,9 @@ // // The provided key must be comparable. func WithValue(parent Context, key, val interface{}) Context { + if key == nil { + panic("nil key") + } if !reflect.TypeOf(key).Comparable() { panic("key is not comparable") }