Conversation
sinsoku
force-pushed
the
fix-bare-super-arguments
branch
2 times, most recently
from
September 27, 2026 14:29
988250d to
5e6ad0c
Compare
sinsoku
marked this pull request as draft
September 27, 2026 15:18
sinsoku
force-pushed
the
fix-bare-super-arguments
branch
2 times, most recently
from
September 27, 2026 16:22
d146108 to
10136d5
Compare
A bare `super` passes the current values of the parameters, including defaults and reassignments, but TypeProf forwarded only what the caller gave, as `...` does. So `def foo(x = 0) = super` called without arguments was reported as a wrong number of arguments for the parent. `...` and anonymous or destructured parameters have no variable the method can reassign, so they are still forwarded as given. A block or lambda parameter can shadow a parameter of the method, so a `super` in it still passes the variable of the method. A named `**rest` that stays empty never ran the box merging the keywords into it, so a keyword default did not reach the parent either. The box now runs once when it is created.
A block took the name of the method it was passed to, so
`[1].map { super }` in `def foo` looked up `map` instead of `foo`. It
now takes the name of the enclosing method, as a lambda literal already
did.
A block outside any method then has no method name, so its `super` is
skipped instead of reported as an undefined method with an empty name.
A block given to define_method or define_singleton_method is the body
of another method, so it has no method name either, and a bare `super`
in it is reported as not supported, as Ruby raises for it at runtime.
sinsoku
force-pushed
the
fix-bare-super-arguments
branch
from
September 27, 2026 17:18
10136d5 to
9dc5adb
Compare
This branch has not been deployed
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.
Motivation / Background
This Pull Request has been created because TypeProf reports valid calls of
superas errors.Detail
superpasses the current values of the parameters, including defaults and reassignments, but TypeProf forwarded only what the caller gave, sharing the implementation of...(Handle mixed and omitted forwarded arguments #434)....and anonymous or destructured parameters are still forwarded that way, as they have no variable the method can reassign. A keyword default also did not reach the parent when the method had a named**restthat stayed empty, as the box merging the keywords into it never ran.superin it looked upmap. It now passes the variables of the method even where a block parameter shadows them. Asuperoutside any method, such as in adefine_methodblock in a class body, now skips the lookup, so it is no longer reported as an undefined method.Verification
The example above reports no errors and infers
A#foo: (Integer, String)andA#bar: (Integer). Each added scenario fails on the commit before its fix.🤖 Generated with Claude Code