Skip to content

Fix generating incorrect accessibility by prototype rb#491

Merged
soutaro merged 1 commit intoruby:masterfrom
pocke:Fix-generating-incorrect-accessibility-by-prototype-rb
Nov 30, 2020
Merged

Fix generating incorrect accessibility by prototype rb#491
soutaro merged 1 commit intoruby:masterfrom
pocke:Fix-generating-incorrect-accessibility-by-prototype-rb

Conversation

@pocke
Copy link
Member

@pocke pocke commented Nov 26, 2020

Problem

I implemented generating accessibility methods in #481 , but it has a bug 🙇‍♂️
It generates incorrect accessibility when methods are continually defined with multiple private def foo() end syntax.

For example:

class C
  private def prv1() end
  private def prv2() end
  def pub() end
end
$ exe/rbs prototype rb test.rb
class C
  private

  def prv1: () -> nil

  def prv2: () -> nil

  def pub: () -> nil
end

it needs public before def pub: () -> nil, but there isn't.

Cause

I misunderstood the usage of Array#slice. It needs to receive the size of the array if I need the entire of the array, but I passed the size - 1.

So this pull request replaces size - 1 with just Array#size

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 merged commit 571c4a2 into ruby:master Nov 30, 2020
@pocke pocke deleted the Fix-generating-incorrect-accessibility-by-prototype-rb branch November 30, 2020 14:57
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

Successfully merging this pull request may close these issues.

2 participants