Skip to content

Attempts at tests and info on how to fix rbs/CommentsAssociator.cc#836

Open
jesse-shopify wants to merge 2 commits intomasterfrom
sorbet-segfault
Open

Attempts at tests and info on how to fix rbs/CommentsAssociator.cc#836
jesse-shopify wants to merge 2 commits intomasterfrom
sorbet-segfault

Conversation

@jesse-shopify
Copy link

@jesse-shopify jesse-shopify commented Jan 21, 2026

Fix crash in CommentsAssociator when processing empty if/else branches in modules

This PR fixes a crash in the RBS comments associator that occurred when processing empty if/else branches inside modules or classes. The issue happened when walkBody was called with a null node pointer from empty if/else branches, causing a null pointer dereference.

Additionally, this PR improves error messages for type alias comments at the top level by providing a more appropriate error note when there's no context to show.

Motivation

When processing Ruby files with empty if/else branches inside modules or classes that contained RBS comments, Sorbet would crash due to a null pointer dereference in CommentsAssociator::walkBody. This pattern appears in some rake files and needed to be handled properly.

Test plan

See included automated tests.

Copy link
Author

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

@jesse-shopify jesse-shopify marked this pull request as ready for review January 21, 2026 17:28
@jesse-shopify jesse-shopify self-assigned this Jan 21, 2026
…ess/else is present

Co-authored-by: Alex Rocha <alex.rocha@shopify.com>
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.

1 participant