Tell super outside a method from super in a define_method block - #497
Merged
Merged
Conversation
A bare `super` without enclosing method arguments reported "implicit
argument passing of super is not supported here" wherever it was, and
`super()` outside a method reported nothing. Ruby raises "super called
outside of method" at the top level, in a class body and in a block
there, and rejects only the bare `super` in a define_method block.
CRef now records whether it is inside a method body, which a
define_method block is although its method name is unknown, so the two
cases are reported with Ruby's wording.
This also lets a define_method block keep the enclosing method's
forward_args, which it had dropped to reject a bare `super`, so `...`
in the block no longer reports the super diagnostic:
def self.m(...)
define_method(:x) { pr(...) }
end
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mame
enabled auto-merge (rebase)
September 28, 2026 13:24
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.
Follow-up to #484.
superwithout a method now reports Ruby's own wording:super called outside of method, for bothsuperandsuper(). Before,super()reported nothing.superin a define_method block:implicit argument passing of super from method defined by define_method() is not supported.To tell these apart,
CRefnow records whether it is inside a method body. A define_method block counts as one even though its method name is unknown.This also fixes
...in a define_method block. The block had dropped the enclosing method's forwarded arguments in order to reject a baresuper, so...there reported the super diagnostic: