Skip to content

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 st0012 force-pushed the support-basic-object branch from 1b2a7d7 to 03ce70e Compare April 25, 2023 23:24
@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?

@st0012
Copy link
Member Author

st0012 commented Nov 30, 2024

@hsbt Thanks for pinging. Yes it does 👍

@st0012 st0012 closed this Nov 30, 2024
@st0012 st0012 deleted the support-basic-object branch November 30, 2024 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants