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

Avoid to generate anonymous or internal module #1421

Merged
merged 1 commit into from
Aug 10, 2023
Merged

Conversation

ksss
Copy link
Collaborator

@ksss ksss commented Aug 10, 2023

Anonymous or internal modules cannot have their names defined as RBS, so they cannot be used even if they get a name. These should be treated as if the name could not be obtained.

Before

$ rbs prototype runtime "NameError*"
class NameError < StandardError
  include DidYouMean::Correctable

  include ErrorHighlight::CoreExt

  public

  def local_variables: () -> untyped

  def name: () -> untyped

  def receiver: () -> untyped

  private

  def initialize: (*untyped) -> void

  class message   #=> Syntax error: expected one of class/module/constant name, token=`message` (tLIDENT)
    def self._load: (untyped) -> untyped

    public

    def ==: (untyped) -> untyped

    def _dump: (untyped) -> untyped

    def to_str: () -> untyped

    private

    def initialize_copy: (untyped) -> untyped
  end
end

After

$ bundle exec rbs prototype runtime "NameError*"
class NameError < StandardError
  include DidYouMean::Correctable

  include ErrorHighlight::CoreExt

  public

  def local_variables: () -> untyped

  def name: () -> untyped

  def receiver: () -> untyped

  private

  def initialize: (*untyped) -> void
end

Anonymous or internal modules cannot have their names defined as RBS, so they cannot be used even if they get a name.
These are treated as if the name could not be obtained.
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.

🙏

@soutaro soutaro added this pull request to the merge queue Aug 10, 2023
Merged via the queue into ruby:master with commit f8e136a Aug 10, 2023
23 checks passed
@ksss ksss deleted the const_name branch August 10, 2023 05:07
@soutaro soutaro added this to the RBS 3.2 milestone Aug 18, 2023
@soutaro soutaro added the Released PRs already included in the released version label Aug 18, 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