Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support BasicObject #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Mar 14, 2023

When investigating ruby/irb#540, I found that pp doesn't support BasicObject. Consider we start supporting it in tools like irb or debug, I think it may be good for pp to start supporting it too.

@st0012
Copy link
Member Author

st0012 commented Apr 26, 2023

Using bind_call on BasicObject works well with CRuby. But with JRuby it raises

NoMethodError: undefined method `respond_to_missing?' for #<BasicObject:0x2da5fdc>

It's probably because the difference in implementation. But I couldn't trace it deeper.

@st0012
Copy link
Member Author

st0012 commented May 14, 2023

@headius 👋 this PR rebinds methods like Kernel#respond_to? to support BasicObject, which is an approach used in both ruby/debug and IRB too. It works for TruffleRuby and CRuby but causes error in JRuby:

Error: test_basic_object(PPTestModule::PPTest): NoMethodError: undefined method `respond_to_missing?' for #<BasicObject:0x56c6d515>
org/jruby/RubyKernel.java:[21](https://github.com/ruby/pp/actions/runs/4803138033/jobs/8547336749?pr=12#step:5:22)82:in `respond_to?'
org/jruby/RubyUnboundMethod.java:169:in `bind_call'
/home/runner/work/pp/pp/lib/pp.rb:204:in `pp'
/home/runner/work/pp/pp/lib/pp.rb:96:in `block in pp'
/home/runner/work/pp/pp/lib/pp.rb:160:in `guard_inspect_key'
/home/runner/work/pp/pp/lib/pp.rb:96:in `pp'
/home/runner/work/pp/pp/test/test_pp.rb:[25](https://github.com/ruby/pp/actions/runs/4803138033/jobs/8547336749?pr=12#step:5:26):in `test_basic_object'

Is this something JRuby can match CRuby's behaviour on? Otherwise, even if this PR is not accepted, the same error would still occur in IRB.

@hsbt
Copy link
Member

hsbt commented Nov 12, 2024

@st0012 Is #26 working with your use-case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants