Skip to content

Commit 1d9409d

Browse files
committed
Ruby 2.7: Proc#<< and Proc#>> raises TypeError if passed not callable object
1 parent f6bd129 commit 1d9409d

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Compatibility:
2222
* Implement `Enumerator#produce` (#2160, @zverok)
2323
* Implement `Complex#<=>` (#2004, @ssnickolay).
2424
* Add warning for `proc` without block (#2004, @ssnickolay).
25+
* `Proc#<<` and `Proc#>>` raises TypeError if passed not callable object (#2004, @ssnickolay).
2526

2627
Performance:
2728

spec/tags/core/proc/compose_tags.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ def to_proc
105105
end
106106

107107
def >>(other)
108+
raise(TypeError, 'callable object is expected') unless other.respond_to?(:call)
109+
108110
if lambda?
109111
-> (*args, &block) do
110112
other.call(call(*args, &block))
@@ -117,6 +119,8 @@ def >>(other)
117119
end
118120

119121
def <<(other)
122+
raise(TypeError, 'callable object is expected') unless other.respond_to?(:call)
123+
120124
if lambda?
121125
-> (*args, &block) do
122126
call(other.call(*args, &block))

test/mri/excludes/TestProc.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
exclude :test_proc_args_rest_post, "needs investigation"
2727
exclude :test_proc_args_rest_post_block, "needs investigation"
2828
exclude :test_safe, "needs investigation"
29-
exclude :test_compose_with_noncallable, "needs investigation"
3029
exclude :test_orphan_return, "needs investigation"
3130
exclude :test_proc_lambda, "needs investigation"
3231
exclude :test_proc_autosplat, "needs investigation"

0 commit comments

Comments
 (0)