ruby-changes:72588
From: Peter <ko1@a...>
Date: Mon, 18 Jul 2022 22:37:10 +0900 (JST)
Subject: [ruby-changes:72588] dd362a786a (master): [ruby/rdoc] Fix call-seq for aliased method with similar names
https://git.ruby-lang.org/ruby.git/commit/?id=dd362a786a From dd362a786af7f5131844652fa85a07539b4da9b8 Mon Sep 17 00:00:00 2001 From: Peter Zhu <peter@p...> Date: Fri, 15 Jul 2022 17:39:21 -0400 Subject: [ruby/rdoc] Fix call-seq for aliased method with similar names deduplicate_call_seq has a bug that skips call-seq for methods where the alias is a prefix of the method name. For example, if the alias name is "each" and the current method name is "each_line", then deduplicate_call_seq will skip all call-seq for "each_line" since it will believe that it is for the alias. https://github.com/ruby/rdoc/commit/1148988ccc --- lib/rdoc/any_method.rb | 4 ++-- test/rdoc/test_rdoc_any_method.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/rdoc/any_method.rb b/lib/rdoc/any_method.rb index 0b7dd717ab..051f946a10 100644 --- a/lib/rdoc/any_method.rb +++ b/lib/rdoc/any_method.rb @@ -350,12 +350,12 @@ class RDoc::AnyMethod < RDoc::MethodAttr https://github.com/ruby/ruby/blob/trunk/lib/rdoc/any_method.rb#L350 ignore << is_alias_for.name ignore.concat is_alias_for.aliases.map(&:name) end - ignore.map! { |n| n =~ /\A\[/ ? n[0, 1] : n} + ignore.map! { |n| n =~ /\A\[/ ? /\[.*\]/ : n} ignore.delete(method_name) ignore = Regexp.union(ignore) matching = entries.reject do |entry| - entry =~ /^\w*\.?#{ignore}/ or + entry =~ /^\w*\.?#{ignore}[$\(\s]/ or entry =~ /\s#{ignore}\s/ end diff --git a/test/rdoc/test_rdoc_any_method.rb b/test/rdoc/test_rdoc_any_method.rb index 826ef1c8d8..6915b466f0 100644 --- a/test/rdoc/test_rdoc_any_method.rb +++ b/test/rdoc/test_rdoc_any_method.rb @@ -51,6 +51,20 @@ method(a, b) { |c, d| ... } https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_any_method.rb#L51 assert_equal 'foo', m.call_seq end + def test_call_seq_alias_for + a = RDoc::AnyMethod.new nil, "each" + m = RDoc::AnyMethod.new nil, "each_line" + + a.call_seq = <<-CALLSEQ +each(foo) +each_line(foo) + CALLSEQ + + m.is_alias_for = a + + assert_equal "each_line(foo)", m.call_seq + end + def test_full_name assert_equal 'C1::m', @c1.method_list.first.full_name end -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/