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

Handle module_function with no arguments #3018

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

vinistock
Copy link
Member

@vinistock vinistock commented Jan 7, 2025

Motivation

Closes #2653

This PR handles the other missing part of module_function, which is when it gets invoked with no argument. After looking into the Ruby source code, it seems that module_func is a flag considered as part of the visibility scope.

Invoking module_function will both:

  1. Start marking new methods as singleton methods
  2. Push private into the stack

Implementation

I created a new VisibilityScope object to help us encapsulate all aspects of visibility, so that we don't forget to handle module_func where necessary.

Then I started handling the case of module_function with no arguments, which essentially pushes a new scope into the stack with module_func: true and visibility private.

Automated Tests

Added a few tests.

@vinistock vinistock added server This pull request should be included in the server gem's release notes enhancement New feature or request labels Jan 7, 2025 — with Graphite App
Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@vinistock vinistock requested review from andyw8 and st0012 January 7, 2025 16:41
@vinistock vinistock marked this pull request as ready for review January 7, 2025 16:42
@vinistock vinistock requested a review from a team as a code owner January 7, 2025 16:42
@vinistock vinistock force-pushed the 01-07-handle_module_function_with_no_arguments branch from 295d45e to f81028f Compare January 7, 2025 18:40
@vinistock vinistock force-pushed the 01-07-handle_module_function_with_no_arguments branch from f81028f to 2ec699e Compare January 7, 2025 18:59
@vinistock vinistock merged commit 460743e into main Jan 7, 2025
44 checks passed
Copy link
Member Author

Merge activity

  • Jan 7, 2:31 PM EST: A user merged this pull request with Graphite.

@vinistock vinistock deleted the 01-07-handle_module_function_with_no_arguments branch January 7, 2025 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request server This pull request should be included in the server gem's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support module_function in the indexer
2 participants