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

Ignore refinements in rbs prototype rb #487

Merged
merged 1 commit into from Nov 24, 2020

Conversation

pocke
Copy link
Member

@pocke pocke commented Nov 23, 2020

rbs prototype rb will ignore refinements by this pull request.

Problem

Currently rbs prototype rb command generates incorrect RBS code for Ruby code that uses refinements.
For example

# test.rb

module M
  refine Array do
    def cool_method() end
  end
end
$ exe/rbs prototype rb test.rb
module M
  def cool_method: () -> nil
end

The cool_method is not M module's method, but prototype rb isn't aware of it.

Solution

Just ignore the body of refine method.
By this change, it just omits methods for refinements.

# For the same test.rb

$ exe/rbs prototype rb test.rb
module M
end

RBS doesn't have support for refinements, so I think we can ignore it.

end
end

def process_children(node, decls:, comments:, context:)
Copy link
Member

Choose a reason for hiding this comment

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

👍

@soutaro soutaro merged commit a0f28c1 into ruby:master Nov 24, 2020
@pocke pocke deleted the Ignore-refinements-in--rbs-prototype-rb- branch November 24, 2020 16:36
tk0miya added a commit to tk0miya/gem_rbs_collection that referenced this pull request Oct 11, 2023
It seems this definition was added to avoid the trouble on `rbs
prototype rb` and refinements.  But it was gone away now because
`rbs prototype rb` command ignores refinements now.

refs: ruby/rbs#487
tk0miya added a commit to tk0miya/gem_rbs_collection that referenced this pull request Oct 23, 2023
It seems this definition was added to avoid the trouble on `rbs
prototype rb` and refinements.  But it was gone away now because
`rbs prototype rb` command ignores refinements now.

refs: ruby/rbs#487
pocke pushed a commit to ruby/gem_rbs_collection that referenced this pull request Oct 28, 2023
It seems this definition was added to avoid the trouble on `rbs
prototype rb` and refinements.  But it was gone away now because
`rbs prototype rb` command ignores refinements now.

refs: ruby/rbs#487
sw-square pushed a commit to sw-square/gem_rbs_collection that referenced this pull request Jan 22, 2024
It seems this definition was added to avoid the trouble on `rbs
prototype rb` and refinements.  But it was gone away now because
`rbs prototype rb` command ignores refinements now.

refs: ruby/rbs#487
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.

None yet

2 participants