Skip to content

Commit

Permalink
Ruby 2.7: Proc#<< and Proc#>> raises TypeError if passed not callable…
Browse files Browse the repository at this point in the history
… object
  • Loading branch information
ssnickolay committed Nov 19, 2020
1 parent f6bd129 commit 1d9409d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Compatibility:
* Implement `Enumerator#produce` (#2160, @zverok)
* Implement `Complex#<=>` (#2004, @ssnickolay).
* Add warning for `proc` without block (#2004, @ssnickolay).
* `Proc#<<` and `Proc#>>` raises TypeError if passed not callable object (#2004, @ssnickolay).

Performance:

Expand Down
4 changes: 0 additions & 4 deletions spec/tags/core/proc/compose_tags.txt

This file was deleted.

4 changes: 4 additions & 0 deletions src/main/ruby/truffleruby/core/proc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ def to_proc
end

def >>(other)
raise(TypeError, 'callable object is expected') unless other.respond_to?(:call)

if lambda?
-> (*args, &block) do
other.call(call(*args, &block))
Expand All @@ -117,6 +119,8 @@ def >>(other)
end

def <<(other)
raise(TypeError, 'callable object is expected') unless other.respond_to?(:call)

if lambda?
-> (*args, &block) do
call(other.call(*args, &block))
Expand Down
1 change: 0 additions & 1 deletion test/mri/excludes/TestProc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
exclude :test_proc_args_rest_post, "needs investigation"
exclude :test_proc_args_rest_post_block, "needs investigation"
exclude :test_safe, "needs investigation"
exclude :test_compose_with_noncallable, "needs investigation"
exclude :test_orphan_return, "needs investigation"
exclude :test_proc_lambda, "needs investigation"
exclude :test_proc_autosplat, "needs investigation"

0 comments on commit 1d9409d

Please sign in to comment.