From b251ce7b33f5c8f5102f8090c36713cbbd18b10e Mon Sep 17 00:00:00 2001 From: Damian Gryski Date: Wed, 27 Apr 2022 10:28:04 -0700 Subject: [PATCH] src/runtime: return a nil pointer for compiler bugs in hashmap code We'll still panic if there's a compiler bug, but at least we'll have smaller code in all the cases where we don't. --- src/runtime/hashmap.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/runtime/hashmap.go b/src/runtime/hashmap.go index 5c9daa47..6b91f9ba 100644 --- a/src/runtime/hashmap.go +++ b/src/runtime/hashmap.go @@ -91,7 +91,8 @@ func hashmapKeyEqualAlg(alg hashmapAlgorithm) func(x, y unsafe.Pointer, n uintpt case hashmapAlgorithmInterface: return hashmapInterfaceEqual default: - panic("unknown hashmap equal algorithm") + // compiler bug :( + return nil } } @@ -104,7 +105,8 @@ func hashmapKeyHashAlg(alg hashmapAlgorithm) func(key unsafe.Pointer, n uintptr) case hashmapAlgorithmInterface: return hashmapInterfacePtrHash default: - panic("unknown hashmap hash algorithm") + // compiler bug :( + return nil } }