File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
src/main/ruby/truffleruby/core Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -357,8 +357,9 @@ def grep(pattern, &block)
357
357
if block_given?
358
358
each do
359
359
o = Truffle . single_block_arg
360
- if pattern === o
361
- Truffle ::RegexpOperations . set_last_match ( $~, block . binding )
360
+ matches = pattern === o
361
+ Truffle ::RegexpOperations . set_last_match ( $~, block . binding )
362
+ if matches
362
363
ary << yield ( o )
363
364
end
364
365
end
@@ -376,25 +377,27 @@ def grep(pattern, &block)
376
377
ary
377
378
end
378
379
379
- def grep_v ( pattern )
380
+ def grep_v ( pattern , & block )
380
381
ary = [ ]
381
382
382
383
if block_given?
383
384
each do
384
385
o = Truffle . single_block_arg
385
- unless pattern === o
386
- # Regexp.set_block_last_match # TODO BJF Aug 1, 2016 Investigate for removal
386
+ matches = pattern === o
387
+ Truffle ::RegexpOperations . set_last_match ( $~, block . binding )
388
+ unless matches
387
389
ary << yield ( o )
388
390
end
389
391
end
390
392
else
391
393
each do
392
394
o = Truffle . single_block_arg
393
395
unless pattern === o
394
- # Regexp.set_block_last_match # TODO BJF Aug 1, 2016 Investigate for removal
395
396
ary << o
396
397
end
397
398
end
399
+
400
+ Truffle ::RegexpOperations . set_last_match ( $~, Truffle . invoke_primitive ( :caller_binding ) )
398
401
end
399
402
400
403
ary
You can’t perform that action at this time.
0 commit comments