Skip to content

Commit 14f0039

Browse files
author
Lillian Zhang
committed
Enumerable:multiple yielded values; pass and untag
1 parent 08187f1 commit 14f0039

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
@@ -960,7 +963,8 @@ def uniq(&block)
960963
result = []
961964
if block_given?
962965
h = {}
963-
each do |e|
966+
each do
967+
e = Primitive.single_block_arg
964968
v = yield(e)
965969
unless h.key?(v)
966970
h[v] = true
@@ -969,7 +973,8 @@ def uniq(&block)
969973
end
970974
else
971975
h = {}
972-
each do |e|
976+
each do
977+
e = Primitive.single_block_arg
973978
unless h.key?(e)
974979
h[e] = true
975980
result << e

0 commit comments

Comments
 (0)