sorbet: Fix the formula test helper block typing - #23397
Merged
Merged
Conversation
- This `formula` helper returning `Class.new(::Formula, &block)` is not of _instance_ type `Formula` (set in 540457b), but `T.class_of(Formula)`. - But the accurate `T.proc.bind(T.class_of(::Formula))` can't be used instead because Sorbet errors with: "Malformed `bind`: Can only bind to simple class names". See #23318 (comment). - Uses of this test helper that need to be typechecked still need `T.bind(self, T.class_of(Formula))` inline until Sorbet can bind to `T.class_of` of a class with a fixed `type_template` (maybe never).
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts Sorbet typing in the RSpec formula test helper to avoid incorrectly typing the helper’s Class.new(::Formula, &block) block as being bound to a Formula instance, which doesn’t match how Ruby evaluates that block (it’s evaluated in the class body context).
Changes:
- Update the
formulahelper block type fromT.proc.bind(::Formula).voidto an unboundT.proc.voidto avoid incorrect instance binding.
Show a summary per file
| File | Description |
|---|---|
| Library/Homebrew/test/support/helper/formula.rb | Fixes the Sorbet signature for the formula helper’s block to avoid an incorrect bind(::Formula) typing. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
issyl0
enabled auto-merge
August 2, 2026 14:59
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Aug 2, 2026
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.
brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?This
formulahelper returningClass.new(::Formula, &block)is not of instance typeFormula(set in 540457b), butT.class_of(Formula).But the accurate
T.proc.bind(T.class_of(::Formula))can't be used instead because Sorbet errors with: "Malformedbind: Can only bind to simple class names". See sorbet: Type blocks at source more precisely thanT.untyped#23318 (comment).Uses of this test helper that need to be typechecked still need
T.bind(self, T.class_of(Formula))inline until Sorbet can bind toT.class_ofof a class with a fixedtype_template(maybe never).