ruby-changes:62424
From: Benoit <ko1@a...>
Date: Thu, 30 Jul 2020 01:10:24 +0900 (JST)
Subject: [ruby-changes:62424] 241244739f (master): Fix arity of Hash#to_proc [Bug #12671]
https://git.ruby-lang.org/ruby.git/commit/?id=241244739f From 241244739f2b721ac7aa0961bd90d904c5e3fff6 Mon Sep 17 00:00:00 2001 From: Benoit Daloze <eregontp@g...> Date: Tue, 28 Jul 2020 20:39:27 +0200 Subject: Fix arity of Hash#to_proc [Bug #12671] diff --git a/hash.c b/hash.c index 358b785..f6581ac 100644 --- a/hash.c +++ b/hash.c @@ -5285,7 +5285,7 @@ hash_proc_call(RB_BLOCK_CALL_FUNC_ARGLIST(key, hash)) https://github.com/ruby/ruby/blob/trunk/hash.c#L5285 static VALUE rb_hash_to_proc(VALUE hash) { - return rb_func_proc_new(hash_proc_call, hash); + return rb_func_lambda_new(hash_proc_call, hash, 1, 1); } static VALUE diff --git a/spec/ruby/core/hash/to_proc_spec.rb b/spec/ruby/core/hash/to_proc_spec.rb index 8b7ddd5..73c96bd 100644 --- a/spec/ruby/core/hash/to_proc_spec.rb +++ b/spec/ruby/core/hash/to_proc_spec.rb @@ -29,6 +29,10 @@ describe "Hash#to_proc" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/hash/to_proc_spec.rb#L29 it "is a lambda" do @proc.should.lambda? end + + it "has an arity of 1" do + @proc.arity.should == 1 + end end it "raises ArgumentError if not passed exactly one argument" do -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/