From 86836905b31f6fa161c784482bbc9ee54c1034ae Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Thu, 23 Aug 2018 10:30:28 -0400 Subject: [PATCH] re-add nil receiver for ModeSet.HasMode --- irc/modes/modes.go | 4 ++++ irc/modes/modes_test.go | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/irc/modes/modes.go b/irc/modes/modes.go index d9f362f1..db4cda13 100644 --- a/irc/modes/modes.go +++ b/irc/modes/modes.go @@ -341,6 +341,10 @@ func NewModeSet() *ModeSet { // test whether `mode` is set func (set *ModeSet) HasMode(mode Mode) bool { + if set == nil { + return false + } + return utils.BitsetGet(set[:], uint(mode)-minMode) } diff --git a/irc/modes/modes_test.go b/irc/modes/modes_test.go index 1faa47d8..9f2b9ac2 100644 --- a/irc/modes/modes_test.go +++ b/irc/modes/modes_test.go @@ -78,7 +78,8 @@ func TestSetMode(t *testing.T) { } func TestNilReceivers(t *testing.T) { - var set ModeSet + set := NewModeSet() + set = nil if set.HasMode(Invisible) { t.Errorf("nil ModeSet should not have any modes")