Skip to content

Commit b55e3ee

Browse files
committed
[GR-19220] Enumerable:multiple yielded values; pass and untag (#2145)
PullRequest: truffleruby/2146
2 parents 16f34a1 + 14f0039 commit b55e3ee

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

spec/tags/core/enumerable/count_tags.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

spec/tags/core/enumerable/uniq_tags.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/main/ruby/truffleruby/core/enumerable.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ def count(item = undefined)
114114
seq = 0
115115
if !Primitive.undefined?(item)
116116
warn 'given block not used', uplevel: 1 if block_given?
117-
each { |o| seq += 1 if item == o }
117+
each do
118+
o = Primitive.single_block_arg
119+
seq += 1 if item == o
120+
end
118121
elsif block_given?
119122
each { |o| seq += 1 if yield(o) }
120123
else
@@ -973,7 +976,8 @@ def uniq(&block)
973976
result = []
974977
if block_given?
975978
h = {}
976-
each do |e|
979+
each do
980+
e = Primitive.single_block_arg
977981
v = yield(e)
978982
unless h.key?(v)
979983
h[v] = true
@@ -982,7 +986,8 @@ def uniq(&block)
982986
end
983987
else
984988
h = {}
985-
each do |e|
989+
each do
990+
e = Primitive.single_block_arg
986991
unless h.key?(e)
987992
h[e] = true
988993
result << e

0 commit comments

Comments
 (0)