Skip to content

Stop ignoring symbols in payload when discovering subconstants #2203

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

Merged
merged 3 commits into from
Feb 14, 2025

Conversation

paracycle
Copy link
Member

Motivation

This would have prevented the recent problem that folks ran into with JSON::Ext::ParserConfig symbol added to json gem in version 2.10.0

Implementation

Since JSON::Ext was a constant defined in the payload, and because its scope definition was empty, we never never considering its subconstants, so missing constants like JSON::Ext::ParserConfig.

By removing the check, we should be able to generate more accurate RBI files, that add the constants that might be missing from payload definitions.

Tests

No new tests, existing tests should pass. I have no idea how I can test this, since it is so coupled with what's defined in the payload.

@paracycle paracycle requested a review from a team as a code owner February 13, 2025 23:49
@KaanOzkan
Copy link
Contributor

Something is wrong with CI, it didn't trigger.

@@ -14,11 +14,10 @@ class Subconstants < Base
sig { override.params(event: ScopeNodeAdded).void }
def on_scope(event)
symbol = event.symbol
return if @pipeline.symbol_in_payload?(symbol) && event.node.empty?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't we do this to avoid polluting gem RBIs with empty redefinitions of stdlib classes? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I was remembering too, but then I realized that this is just the listener that is responsible for discovering subconstants and pushing them into the pipeline. Skipping empty scopes of symbols that are in the payload shouldn't be the responsibility of this step.

I will check this against Core as well, but I think, as we improve the fidelity of the gem attribution of mixins and methods, this will be less and less relevant.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you figure this out and we do need this check, please add a comment explaining why we skip 😂

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any empty definitions in core. I'm just seeing a 10s(~5%) increase in gem --all time, not too bad.

@paracycle
Copy link
Member Author

Something is wrong with CI, it didn't trigger.

Yeah, I noticed that too.

This change makes Tapioca consider subconstants of symbols that may already be defined in the payload, ensuring that all relevant subconstants are discovered and processed correctly.

This prevents a case where a new subconstant is defined in a default gem that doesn't get picked up by the payload yet, causing Tapioca to miss it and not generate the corresponding RBI file.
@paracycle paracycle force-pushed the uk-consider-more-subconstants branch from 1aa759f to 21dd01c Compare February 14, 2025 14:40
@paracycle
Copy link
Member Author

@KaanOzkan I rebased on main and did a force-push, which seems to have fixed CI

@paracycle paracycle added the enhancement New feature or request label Feb 14, 2025
@paracycle
Copy link
Member Author

Ok, the CI is green on this PR both in here and in Core.

@paracycle paracycle merged commit 73381f3 into main Feb 14, 2025
18 of 19 checks passed
@paracycle paracycle deleted the uk-consider-more-subconstants branch February 14, 2025 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants