Open
Conversation
69b556c to
2990ac5
Compare
st0012
reviewed
Feb 25, 2026
lib/irb/command/ls.rb
Outdated
|
|
||
| klass = (obj.class == Class || obj.class == Module ? obj : obj.class) | ||
| klass = Kernel.instance_method(:class).bind(obj).call | ||
| is_class_or_module = klass == Class || klass == Module |
Member
There was a problem hiding this comment.
Maybe we can just do Kernel.instance_method(:is_a?).bind(obj).call(Module)? If an object is a Class, it's definitely a Module as well.
Contributor
Author
There was a problem hiding this comment.
I didn't think about that, but it's true! I just kept it as it was but I'll change it.
Contributor
Author
There was a problem hiding this comment.
It's not necessarily easier to read though:
- is_class_or_module = klass == Class || klass == Module
+ is_class_or_module = Kernel.instance_method(:is_a?).bind(obj).call(Module)
Contributor
Author
There was a problem hiding this comment.
That's neat! I changed it 👍
bc0baa1 to
301bf3f
Compare
Contributor
Author
|
Just rebased it on master to make the prism test pass... |
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.
When working with the
buildergem I noticed that the irb inspection of theBuilder::XmlMarkupinstances was not working as expected. Upon further investigation it turns out, that the reason is that this class inherits fromBasicObjectdirectly and not from the more commonObject.You can see the problem here:
I have also created a new
lscommand test file containing a failing test which you can see below: https://github.com/ruby/irb/actions/runs/22390651625/job/64811518726The test is fixed with the second commit of this PR by using a slightly different way to inspect the
class.singleton_classandinstance_variablesof an object.PS: The prism-latest test failure is because the syntax of ruby 4.1 allows trailing commas in method definitions and this change is addressed here: #1178