Skip to content

Commit a40b9df

Browse files
committed
🐛 Do not automatically freeze SearchResult
This was backward incompatible with existing usage of search results: * Fixes #262
1 parent 153e69f commit a40b9df

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

lib/net/imap/search_result.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class IMAP
99
# For backward compatibility, SearchResult inherits from Array.
1010
class SearchResult < Array
1111

12-
# Returns a frozen SearchResult populated with the given +seq_nums+.
12+
# Returns a SearchResult populated with the given +seq_nums+.
1313
#
1414
# Net::IMAP::SearchResult[1, 3, 5, modseq: 9]
1515
# # => Net::IMAP::SearchResult[1, 3, 5, modseq: 9]
@@ -22,19 +22,15 @@ def self.[](*seq_nums, modseq: nil)
2222
# §3.1.6]}[https://www.rfc-editor.org/rfc/rfc7162.html#section-3.1.6].
2323
attr_reader :modseq
2424

25-
# Returns a frozen SearchResult populated with the given +seq_nums+.
25+
# Returns a SearchResult populated with the given +seq_nums+.
2626
#
2727
# Net::IMAP::SearchResult.new([1, 3, 5], modseq: 9)
2828
# # => Net::IMAP::SearchResult[1, 3, 5, modseq: 9]
2929
def initialize(seq_nums, modseq: nil)
3030
super(seq_nums.to_ary.map { Integer _1 })
3131
@modseq = Integer modseq if modseq
32-
freeze
3332
end
3433

35-
# Returns a frozen copy of +other+.
36-
def initialize_copy(other); super; freeze end
37-
3834
# Returns whether +other+ is a SearchResult with the same values and the
3935
# same #modseq. The order of numbers is irrelevant.
4036
#

test/net/imap/test_search_result.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@
66
class SearchDataTests < Test::Unit::TestCase
77
SearchResult = Net::IMAP::SearchResult
88

9-
test "#frozen?" do
10-
assert SearchResult.new([1, 3, 5]).frozen?
11-
assert SearchResult[1, 3, 5].frozen?
12-
assert SearchResult[1, 3, 5, modseq: 9].frozen?
13-
assert SearchResult[1, 3, 5, modseq: 9].clone.frozen?
14-
assert SearchResult[1, 3, 5, modseq: 9].dup.dup.frozen?
15-
end
16-
179
test "#modseq" do
1810
assert_nil SearchResult[12, 34].modseq
1911
assert_equal 123_456_789, SearchResult[12, 34, modseq: 123_456_789].modseq

0 commit comments

Comments
 (0)