#7 new
Brian Ford

Adding proxy methods in lazy_array.rb doesn't account for assignment methods

Reported by Brian Ford | February 24th, 2009 @ 05:44 PM

LazyArray dynamically defines all the Array and Enumerable instance methods on itself. However, it does not account for the difference in assignment methods. While you can define a method as follows in Ruby, you can't call it directly (you can #send to it though):


$ irb
>> def foo=(*args, &block)
>> p args, block
>> end
=> nil
>> args = [:a, :b, :c]
=> [:a, :b, :c]
>> block = lambda { 1 }
=> #<Proc:0x005d4f30@(irb):5>
>> foo = *args, &block
SyntaxError: compile error
(irb):6: syntax error, unexpected ',', expecting $end
foo = *args, &block
            ^
        from (irb):6

This causes an exception in Rubinius where we have same addition accessors on Array:

http://pastie.org/399089

Comments and changes to this ticket

  • Brian Ford

    Brian Ford February 24th, 2009 @ 06:03 PM

    Here's one possible patch.

    
    5c5,7
    <   ((Array.instance_methods(false) | Enumerable.instance_methods(false)).map { |m| m.to_s } - %w[ taguri= ]).each do |method|
    ---
    >   proxy_methods = Array.instance_methods(false) | Enumerable.instance_methods(false)
    >   proxy_methods.map! { |name| name.to_s }
    >   proxy_methods.select { |name| name !~ /=$/ }.each do |method|
    
  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) February 25th, 2009 @ 03:17 AM

    Brian, I just pushed a fix to extlib a moment ago:

    http://github.com/datamapper/ext...

    Would you mind giving it a spin and let me know if it resolves this issue for you?

  • Brian Ford

    Brian Ford March 30th, 2009 @ 03:20 AM

    Hi Dan,

    Yes, the change loads on Rubinius. Sorry about taking so long to get back to you.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Lightweight fast Ruby core extensions library for DataMapper and Merb.

People watching this ticket

Pages