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

RubyArray#flatten! uses `respond_to?` unlike the original [lotus] #2563

Closed
PragTob opened this Issue Feb 4, 2015 · 5 comments

Comments

Projects
None yet
4 participants
@PragTob
Copy link

PragTob commented Feb 4, 2015

Noticed while running through lotus/controller for JRuby compatibility.

On a fairly recent master master (updated an hour ago or so) the following behaviour is observable:

jruby-head:

jruby-head :003 > [BasicObject.new].flatten!
NoMethodError: undefined method `respond_to?' for #<BasicObject:0x7c24d3f1>
    from org/jruby/RubyArray.java:2841:in `flatten!'
    from (irb):3:in `evaluate'
    from org/jruby/RubyKernel.java:1000:in `eval'
    from org/jruby/RubyKernel.java:1310:in `loop'
    from org/jruby/RubyKernel.java:1120:in `catch'
    from org/jruby/RubyKernel.java:1120:in `catch'
    from /home/tobi/.rvm/rubies/jruby-head/bin/irb:13:in `__script__'

vs. 2.2.0:

2.2.0 :006 > [BasicObject.new].flatten!
 => nil

This makes a spec in lotus/controller fail.

This seems reasonably easy to fix - time is scarce as always but I'd love to give this a shot this weekend (will hopefully get to it) - but I gotta setup the whole JRuby project first, we'll see :) However, anyone - don't let that stop you! :)

On a larger scale, though - it seems like almost nothing should use respond_to? as a BasicObject might not have that.

Cheers,
Tobi

@sh286

This comment has been minimized.

Copy link
Member

sh286 commented Mar 25, 2015

Hi @PragTob
Any progress on this?

@PragTob

This comment has been minimized.

Copy link
Author

PragTob commented Mar 25, 2015

Hey @lucasallan - no unfortunately not, no time. I'd still love to get my hands on this but no guarantees and even if I really pushed it would happen at the easter weekend at the earlies.

@sh286

This comment has been minimized.

Copy link
Member

sh286 commented Mar 25, 2015

@PragTob no worries, let us know if you need any help.

@headius

This comment has been minimized.

Copy link
Member

headius commented May 22, 2015

I'm sure this is just blindly dispatching to respond_to? rather than checking if it exists first. Will compare with MRI.

@deepj

This comment has been minimized.

Copy link

deepj commented May 22, 2015

The problem lies in Lotus::Kernel.Array.
https://github.com/lotus/controller/blob/master/lib/lotus/controller/configuration.rb#L393

@headius you can isolate it via this test:

git clone git@github.com:lotus/controller.git
cd controller
bundle
ruby -Itest test/configuration_test.rb --name 'test_0003_raises an error if the given mime type cannot be coerced into string'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.