Forum: IronRuby Issues with Method#to_proc

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Daniele A. (Guest)
on 2009-01-10 15:17
(Received via mailing list)

Today I was writing some code which uses Method#to_proc but I've
encountered a few issues. The following line throws a

proc = 0.method(:to_s).to_proc

I took a look at the source code of the ToProc method of MethodOps and
there's a comment which states that creating Procs out of CLR methods
is basically not yet supported. OK, so it seems reasonable given that,
as far as I understand, built-in library methods actually are CLR
methods internally.

Now, what if I try to create procs out of methods defined in ruby?

class Fixnum
    alias :__to_s :to_s
    def to_s

proc = 0.method(:to_s).to_proc

The original Fixnum#to_s has been aliased and Fixnum#to_s now responds
to a method defined at runtime in ruby, but then I get the following

`to_proc': Unable to cast object of type
'System.Func`3[System.Object,IronRuby.Builtins.Proc,System.Object]' to
type 'IronRuby.Runtime.Calls.BlockCallTarget0'.
        from :0

This exception is raised in the Create method of BlockDispatcher.

Should I file a bug? Or is this totally expected to happen because
Method#to_proc is still incomplete / in its early stages (if so, the
reported issue could fall into this bug report
Tomas M. (Guest)
on 2009-01-10 19:49
(Received via mailing list)
Could you please add your comment to bug #20297?

This topic is locked and can not be replied to.