From 1d9409dc2303858cb9448b6391d335b4cfe294d0 Mon Sep 17 00:00:00 2001 From: Nikolay Sverchkov Date: Wed, 18 Nov 2020 21:44:48 +0300 Subject: [PATCH] Ruby 2.7: Proc#<< and Proc#>> raises TypeError if passed not callable object --- CHANGELOG.md | 1 + spec/tags/core/proc/compose_tags.txt | 4 ---- src/main/ruby/truffleruby/core/proc.rb | 4 ++++ test/mri/excludes/TestProc.rb | 1 - 4 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 spec/tags/core/proc/compose_tags.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 32544162bd80..3b361dc78702 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/spec/tags/core/proc/compose_tags.txt b/spec/tags/core/proc/compose_tags.txt deleted file mode 100644 index 1af3a3383a74..000000000000 --- a/spec/tags/core/proc/compose_tags.txt +++ /dev/null @@ -1,4 +0,0 @@ -fails:Proc#<< raises TypeError if passed not callable object -fails:Proc#<< does not try to coerce argument with #to_proc -fails:Proc#>> raises TypeError if passed not callable object -fails:Proc#>> does not try to coerce argument with #to_proc diff --git a/src/main/ruby/truffleruby/core/proc.rb b/src/main/ruby/truffleruby/core/proc.rb index e9e7628e7c73..a54d973b0b90 100644 --- a/src/main/ruby/truffleruby/core/proc.rb +++ b/src/main/ruby/truffleruby/core/proc.rb @@ -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)) @@ -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)) diff --git a/test/mri/excludes/TestProc.rb b/test/mri/excludes/TestProc.rb index d42f7633c518..d18c6d25e54f 100644 --- a/test/mri/excludes/TestProc.rb +++ b/test/mri/excludes/TestProc.rb @@ -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"