ruby-changes:55312
From: marcandre <ko1@a...>
Date: Sat, 13 Apr 2019 09:56:16 +0900 (JST)
Subject: [ruby-changes:55312] marcandRe: r67519 (trunk): Proc.new: change deprecation warning for clarity (issue #15539)
marcandre 2019-04-13 09:56:12 +0900 (Sat, 13 Apr 2019) New Revision: 67519 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67519 Log: Proc.new: change deprecation warning for clarity (issue #15539) Modified files: trunk/proc.c trunk/spec/ruby/core/kernel/proc_spec.rb trunk/spec/ruby/core/proc/new_spec.rb Index: proc.c =================================================================== --- proc.c (revision 67518) +++ proc.c (revision 67519) @@ -710,7 +710,7 @@ proc_new(VALUE klass, int8_t is_lambda) https://github.com/ruby/ruby/blob/trunk/proc.c#L710 rb_raise(rb_eArgError, proc_without_block); } else { - rb_warn(proc_without_block); + rb_warn("Capturing the given block using Proc.new is deprecated; use `&block` instead"); } } #else Index: spec/ruby/core/kernel/proc_spec.rb =================================================================== --- spec/ruby/core/kernel/proc_spec.rb (revision 67518) +++ spec/ruby/core/kernel/proc_spec.rb (revision 67519) @@ -56,7 +56,7 @@ describe "Kernel#proc" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/proc_spec.rb#L56 -> { some_method { "hello" } - }.should complain(/tried to create Proc object without a block/) + }.should complain(/Capturing the given block using Proc.new is deprecated/) end end Index: spec/ruby/core/proc/new_spec.rb =================================================================== --- spec/ruby/core/proc/new_spec.rb (revision 67518) +++ spec/ruby/core/proc/new_spec.rb (revision 67519) @@ -194,11 +194,11 @@ describe "Proc.new without a block" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/proc/new_spec.rb#L194 ruby_version_is "2.7" do it "can be created if invoked from within a method with a block" do - lambda { ProcSpecs.new_proc_in_method { "hello" } }.should complain(/tried to create Proc object without a block/) + lambda { ProcSpecs.new_proc_in_method { "hello" } }.should complain(/Capturing the given block using Proc.new is deprecated/) end it "can be created if invoked on a subclass from within a method with a block" do - lambda { ProcSpecs.new_proc_subclass_in_method { "hello" } }.should complain(/tried to create Proc object without a block/) + lambda { ProcSpecs.new_proc_subclass_in_method { "hello" } }.should complain(/Capturing the given block using Proc.new is deprecated/) end @@ -209,7 +209,7 @@ describe "Proc.new without a block" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/proc/new_spec.rb#L209 -> { some_method { "hello" } - }.should complain(/tried to create Proc object without a block/) + }.should complain(/Capturing the given block using Proc.new is deprecated/) end end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/