Rebind self in Class.new blocks; nested blocks inherit rebound binders - #1310
Draft
apiology wants to merge 1 commit into
Draft
Rebind self in Class.new blocks; nested blocks inherit rebound binders#1310apiology wants to merge 1 commit into
apiology wants to merge 1 commit into
Conversation
Two changes so strong typecheck resolves define_method (and any other Module method) inside Class.new blocks: 1. Core fill: Class#new gets @yieldreceiver [::Class]. RBS records the binding only on Class#initialize ([self: Class], rbs >= 4.1); Class#new, the method actually resolved for Class.new-with-a-block, is (*untyped, **untyped) -> untyped in every RBS version, so a translator fix for [self: ...] would not reach this call site. 2. Pin::Block#rebind/#binder cascade: a block with no rebind of its own inherits its enclosing block's rebound binder instead of falling back to its statically-parsed context. Matches Ruby semantics (a block does not change self) and makes the existing class_eval/instance_eval fills work below one level of block nesting. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01H1FEjW6nMpZrWPmeWX9miT
apiology
added a commit
to apiology/solargraph
that referenced
this pull request
Aug 17, 2026
…er inheritance # Conflicts: # spec/type_checker/levels/strong_spec.rb
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.
At strong typecheck, calls that Ruby resolves fine inside
Class.newblocks are flagged:Two changes:
Class#newgets@yieldreceiver [::Class]. RBS records this binding only onClass#initialize([self: Class], rbs >= 4.1);Class#new— the method actually resolved forClass.new { ... }— is(*untyped, **untyped) -> untypedin every RBS version, so a[self: ...]translator fix would not reach this call site. The runtime type is parameterized by the superclass argument, which@yieldreceivercan't express, so the fill matches RBS's own unparameterizedClass.Pin::Block#rebind/#bindercascade: a block with no rebind of its own inherits its enclosing block's rebound binder instead of its statically-parsed context. Blocks don't changeself; without this, every existing fill (class_eval,instance_eval, ...) stops applying one nesting level down.Three new strong-level specs (direct,
.each-nested,class_eval-nested).🤖 This PR was written by Claude (Claude Code), operated by @apiology.
🤖 Generated with Claude Code
https://claude.ai/code/session_01H1FEjW6nMpZrWPmeWX9miT