Bug #9242


Rdoc detection of aliases

Added by marcandre (Marc-Andre Lafortune) almost 8 years ago. Updated over 1 year ago.

Target version:
ruby -v:
2.1.0 preview


The online doc appears to be making bad detection of aliases.

For example, Array#map and Array#collect are not marked as aliases (on either or

On the other hand, when aliases are detected, the generated method interface and the name of the method it is aliases to are always the same for both methods.

For example, the doc for Array#find_index says it is an alias to find_index and has interface showing index (again on both sites), e.g.

It might also be a good idea to always have doc examples using both forms in case of aliases.

Updated by Hanmac (Hans Mackowiak) almost 8 years ago

Array#map and Array#collect are not real aliases
both methods are defined with the excact same method body function but both are not calling each other,
so changeing one method doe not break the other

Updated by zzak (Zachary Scott) almost 8 years ago

  • Status changed from Open to Assigned
  • Assignee changed from drbrain (Eric Hodel) to zzak (Zachary Scott)

Alias detection was updated in the pre-release of RDoc 4.1.0, can you try to test it?

If it's these methods are using the same method, we can easily fix this by adding another signature to the call-seq example. What do you think?

Updated by drbrain (Eric Hodel) almost 8 years ago

  • Assignee changed from zzak (Zachary Scott) to drbrain (Eric Hodel)
  • Target version set to 2.6

As Hanmac noted, they aren't real aliases:

$ grep rb_ary_collect array.c
rb_ary_collect(VALUE ary)
rb_ary_collect_bang(VALUE ary)
rb_define_method(rb_cArray, "collect", rb_ary_collect, 0);
rb_define_method(rb_cArray, "collect!", rb_ary_collect_bang, 0);
rb_define_method(rb_cArray, "map", rb_ary_collect, 0);
rb_define_method(rb_cArray, "map!", rb_ary_collect_bang, 0);

But I guess this is for performance reasons (can someone confirm?). I suppose RDoc should treat these as aliases.

Updated by marcandre (Marc-Andre Lafortune) almost 8 years ago

There really shouldn't be a difference between using rb_define_alias and using the same rb_define_method.

In Ruby, Array.instance_method(:map) == Array.instance_method(:collect) returns true (even when not defined using rb_define_alias), and they should be treated as aliases.

Moreover, the problem isn't there, since Array#find_index and index are not defined using rb_define_alias either but the generated doc sees them as aliases.

Updated by zzak (Zachary Scott) over 7 years ago

  • Category changed from doc to lib
Actions #6

Updated by naruse (Yui NARUSE) almost 4 years ago

  • Target version deleted (2.6)

Updated by jeremyevans0 (Jeremy Evans) about 2 years ago

  • Backport deleted (1.9.3: UNKNOWN, 2.0.0: UNKNOWN)

This is still an issue in the master branch. I've added a pull request for rdoc that will treat rb_define_method to the same C function as an alias (similar to rb_define_alias):

Actions #8

Updated by jeremyevans0 (Jeremy Evans) over 1 year ago

  • Status changed from Assigned to Closed

Also available in: Atom PDF