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

fix: alias to a method with call-seq should render properly if the call-seq does not specify the alias #840

Merged
merged 1 commit into from
Oct 15, 2021

Conversation

flavorjones
Copy link
Contributor

@flavorjones flavorjones commented Sep 20, 2021

Description of the problem

Fixes #792.

If I have this ruby code:

class Foo
  # :call-seq:
  #   foo(a)
  #   foo(a, b)
  #   foo(a, b, c)
  def foo(*args)
  end

  alias :bar :foo
end

The alias bar is rendered poorly:

foo

After this change, it gracefully falls back to using the underlying method's param-seq:

Screenshot from 2021-09-20 10-21-59

Explanation

The call-seq deduplication introduced in b792230 and refined in 0ead786 returns a blank string if the alias's underlying method does not name the alias in its call-seq.

This change fixes alias call-seq to return nil in this case, which in turn means that the darkfish template will use #param_seq instead of rendering with a missing method-heading div.

This change also backfills test coverage for b792230 and 0ead786 to ensure deduplication still works as expected.

This change fixes alias call-seq to return nil if the method's
call-seq does not specify the alias.

Previously, the alias's call-seq would be an empty string in this case
which broke darkfish rendering.

This change also backfills test coverage for 0ead786 which moved
call-seq deduplication into AnyMethod.
@tenderlove tenderlove merged commit c749f60 into ruby:master Oct 15, 2021
@flavorjones flavorjones deleted the flavorjones/alias-call-seq-fix branch February 2, 2024 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Call-seq not honored in a certain case
2 participants