Accessors arity in MRI and JRuby


#1

Hi all,

I noticed a difference in the arity of accessors between MRI and JRuby:

MRI

VERSION = 1.8.6-p287
CMD = ~/.multiruby/install/1.8.6-p287/bin/ruby -S irb

irb(main):001:0> class Foo
irb(main):002:1> attr_accessor :bar
irb(main):003:1> end
=> nil
irb(main):004:0> Foo.new.method(:bar=).arity
=> 1

JRuby

irb(main):001:0> class Foo
irb(main):002:1> attr_accessor :bar
irb(main):003:1> end
=> nil
irb(main):008:0> Foo.new.method(:bar=).arity
=> -1

JRuby returns -1 for the accessor :bar while MRI 1.8.6 returns 1. What’s
the meaning of this difference?

Thanks in advance.
Andrea


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#2

Andrea F. wrote:

Hi all,

I noticed a difference in the arity of accessors between MRI and JRuby:

JRuby returns -1 for the accessor :bar while MRI 1.8.6 returns 1. What’s
the meaning of this difference?

Probably nothing; we should fix our accessors to be arity 1.

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#3

I have a fix for this ready. Would it be possible for you to add some
arity specs to RubySpec, for this and for some other cases? And of
course, a JRuby bug should be filed :slight_smile:

Andrea F. wrote:

irb(main):002:1> attr_accessor :bar
=> nil


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#4

Il giorno dom, 31/05/2009 alle 15.13 -0700, Charles Oliver N. ha
scritto:

Would it be possible for you to add some
arity specs to RubySpec, for this and for some other cases? And of
course, a JRuby bug should be filed :slight_smile:

Hi Charles,

yes it’s possible but I need some time to get confident with the
RubySpec project. Meanwhile I’ll open a ticket for the bug on codehaus.

Andrea


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email