Add overloads_strategy option to RBSCommentsToSorbetSigs#921
Open
Morriar wants to merge 2 commits into
Open
Conversation
When a method has multiple `#:` annotations (RBS overloads), the translator emits multiple consecutive `sig` blocks which sorbet-runtime rejects at load time with "You called sig twice without declaring a method in between". Add an `overloads_strategy` keyword parameter that accepts `:translate_all` (default, current behavior), `:translate_last` (keep only the last signature), or `:raise` (raise Translate::Error). Fixes #913
000878e to
067d8cf
Compare
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
paracycle
reviewed
May 14, 2026
| when :translate_all | ||
| signatures | ||
| when :translate_last | ||
| kept = signatures.first #: as RBS::Signature |
Member
There was a problem hiding this comment.
It is strange that we keep first in a branch that says ..._last. Do we get the signatures in reverse order? It might be good to add a note here to that effect.
amomchilov
reviewed
May 14, 2026
| end | ||
| [kept] | ||
| else # :raise | ||
| raise Error, "Method has multiple overloaded signatures" |
Contributor
There was a problem hiding this comment.
Can we give more context on which method, where? This could be hard to find.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a method has multiple
#:annotations (RBS overloads),RBSCommentsToSorbetSigsemits multiple consecutivesigblocks.sorbet-runtimerejects this at load time with:This breaks
tapioca gemfor any gem using overloaded RBS annotations (e.g. the commoneachwith-block/without-block pattern).This PR adds an
overloads_strategykeyword parameter torbs_comments_to_sorbet_sigsthat accepts one of three symbols::translate_all(default) -- current behavior, translates all overloads into separatesigblocks. No breaking change.:translate_last-- keeps only the last signature (closest to the method def, matching Sorbet's "last sig wins" semantics) and removes the others.:raise-- raisesTranslate::Error, allowing callers like tapioca to rescue and fall back to the original source.Fixes #913