Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: incorrect interpretation of alias #247

Closed
adrianomitre opened this issue Jan 26, 2011 · 2 comments
Closed

bug: incorrect interpretation of alias #247

adrianomitre opened this issue Jan 26, 2011 · 2 comments
Milestone

Comments

@adrianomitre
Copy link

Aliasing an existing method prior to wrapping makes YARD wrongly report the new name as an alternative name to the wrapper -- instead of to the wrapped.

Minimal example:
class Array
alias original_size size
def size # prints the "effective" size
self.compact.original_size
end
end
The following is an extract of what YARD generates for the above:

Instance Method Details
- (Object) size
Also known as: original_size

the last statement of which is simply wrong: #size and #original_size are different methods. The correct statement should go along the lines

Instance Method Details
- (Object) size
Note: this is a redefinition, the method originally named size was aliased as original_size.

YARD behaviour seems to result from not taking position into account, i.e., disregarding the place in the code where the alias ocurred. If the alias command was placed after the method definition, YARD report would be right (although the method logic would be wrong and a SystemStackError would be raised if the method were ever called).

@lsegal
Copy link
Owner

lsegal commented Feb 25, 2011

Effectively, any method declaration (def ...) should just wipe any alias info for that method. I'm not sure the note is of much use, or perhaps that's information that can be added later.

@lsegal
Copy link
Owner

lsegal commented Mar 11, 2011

Splice any alias references on method (re-)definitions into separate methods

You can add extra documentation information for the alias itself as comments
in the alias (or alias_method) statement. For instance,

# Foo Bar
def foo; "Hello" end

# @deprecated
alias bar foo

# NOT FOO!
def foo; 2 end

Will turn 'bar' into its own method with docstring 'Foo Bar' and a
@deprecated tag. 'foo' will be redefined to have the docstring 'NOT FOO!'.

The alias information will be removed, and the methods will be considered
separate.

Closed by d2c0d72

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants