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

[prototype runtime] Avoid alias for methods defined in another module #1457

Merged
merged 1 commit into from
Aug 25, 2023

Conversation

ksss
Copy link
Collaborator

@ksss ksss commented Aug 23, 2023

define_method and define_singleton_method can take UnboundMethod in second argument.
In addition, it can be specified even for methods of a completely different module.

For example, erubi uses this technique.

https://github.com/jeremyevans/erubi/blob/4d24561e79e291208996892800a5cb9d11b8d2af/lib/erubi.rb#L23

rbs prototype runtime produces the following output for the current erubi.

$ rbs prototype runtime -r erubi Erubi
module Erubi
  alias self.h self.html_escape 

  ...snip...

However, the specified method does not exist.

Unknown method alias name: html_escape => h (::Erubi) (RBS::UnknownMethodAliasError)

    alias self.h self.html_escape
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

To avoid this problem, I suggest that in this case the output be as a method definition, not an alias.

Copy link
Member

@soutaro soutaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@soutaro soutaro added this to the RBS 3.3 milestone Aug 25, 2023
@soutaro soutaro enabled auto-merge August 25, 2023 03:10
@soutaro soutaro added this pull request to the merge queue Aug 25, 2023
Merged via the queue into ruby:master with commit c2924ab Aug 25, 2023
@ksss ksss deleted the erubi branch August 25, 2023 03:31
@soutaro soutaro added the Released PRs already included in the released version label Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Released PRs already included in the released version
Development

Successfully merging this pull request may close these issues.

2 participants