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

Fix singleton indexing under compact namespaces #3062

Merged

Conversation

vinistock
Copy link
Member

@vinistock vinistock commented Jan 14, 2025

Motivation

Fixes one of the bugs reported in #3050

We were assigning incorrect names to singleton classes defined inside compact namespaces. The issue is that we were simply taking the last entry in the stack, but when using compact namespaces that entry may include multiple names.

Implementation

Started ensuring we use only the last part of the name to define the singleton.

I also noticed that we were pushing and popping from the name stack when entering a singleton method defined with def self.foo. That's actually unnecessary. The name stack is only used for constants and inside a method definition we'll only find instance variables (which use the owner stack rather than the name stack).

I removed the pushing and popping in that case.

Automated Tests

Added a test.

@vinistock vinistock added bugfix This PR will fix an existing bug server This pull request should be included in the server gem's release notes labels Jan 14, 2025 — with Graphite App
@vinistock vinistock requested review from andyw8 and st0012 January 14, 2025 14:31
Copy link
Member Author

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

@vinistock vinistock requested a review from alexcrocha January 14, 2025 14:31
@vinistock vinistock marked this pull request as ready for review January 14, 2025 14:34
@vinistock vinistock requested a review from a team as a code owner January 14, 2025 14:34
@vinistock vinistock merged commit 77337ef into main Jan 14, 2025
46 checks passed
@vinistock vinistock deleted the 01-14-fix_singleton_indexing_under_compact_namespaces branch January 14, 2025 15:17
@jesseduffield
Copy link

Thanks for making this @vinistock! When might I expect to see this in a release?

@vinistock
Copy link
Member Author

We cut releases pretty often. I have a few bug fix PRs up that I'd like to include and then we can ship.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This PR will fix an existing bug 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.

3 participants