`self.private :foo` is reported as an invalid visibility call and ignored
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- developer-experience, tooling
Research direction
Reproduce with the snippet in the issue body, then find the handler that emits InvalidMethodVisibility for private/protected/public/module_function. Compare with how include, prepend, extend, and private_constant already accept a self receiver, and make the visibility handlers do the same. Done looks like the expected Ruby 3.2 output: no diagnostics and the visibility/module-function applied.
Written by the indexing model from the issue text.
Description
Since Ruby 2.7, private methods can be called with a literal self receiver, so self.private :foo, self.protected, and self.module_function :foo behave the same as their receiverless forms. Rubydex rejects every receiver for private, protected, public, and module_function, including self. It reports an InvalidMethodVisibility diagnostic and does not apply the visibility.
Other handlers already treat self like an implicit receiver: include, prepend, extend, private_constant, and private_class_method.
Reproduction
class Foo
def foo; end
self.private :foo
self.protected
def bar; end
end
module Bar
def baz; end
self.module_function :baz
end
Ruby 3.2:
Foo.private_instance_methods(false) # => [:foo]
Foo.protected_instance_methods(false) # => [:bar]
Bar.respond_to?(:baz) # => true
Expected
No diagnostics. foo is private, bar is protected, and Bar.baz is a module function.
Actual
Three diagnostics, for example InvalidMethodVisibility: `private` cannot be called with an explicit receiver. No MethodVisibility definitions are created, and bar stays public.
- Dominant language
- Rust
- Stars
- 382
- Forks
- 30
- Avg merge
- 16h 57m
- Merged PRs (30d)
- 10
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Shopify/rubydex
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
Constant reference unresolved inside a class nested in its own superclass when the outer namespace is only implied by compact definitionsPossibly taken @efegokdemir claimed this 29 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Maintainers usually reply within 1 day
-
Expose comment groups that aren't attached to a definitionPossibly taken @efegokdemir claimed this 31 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
Incorrect resolved superclass namePossibly taken @efegokdemir claimed this 38 days ago. Openbug roundhouse
Difficulty 4/5 1-2 days Newbie friendliness 25/100
Maintainers usually reply within 1 day
-
`resolve_constant` returns nil for names with three or more segmentsPossibly taken @vinistock claimed this 33 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 65/100
Maintainers usually reply within 1 day
Similar issues
-
CI/CD ignore-for-release
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
eclipse-ankaios/ankaios#844 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
std: `SliceIndex<str>` missing for `std::ops` ranges, so generic `R: SliceIndex<str>` bounds failOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
symposium-dev/symposium#530 ·
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day