Big problem with debian ruby 1.8.0-1

Discussion in 'Ruby' started by Ferenc Engard, Oct 5, 2003.

  1. Hello,

    I have just upgraded ruby on my debian unstable to ruby 1.8.0-1
    (2003-10-05), and my program has crashed. Here is the stripped down
    version of my code:

    ----------------------------------------------------------------------
    #!/usr/bin/ruby1.8

    class Action < Proc
    attr_accessor :name
    def initialize
    puts "Action#init"
    @name='not defined'
    super
    end
    end

    class Actions
    def initialize
    @actions=Hash.new
    end

    #~ def register(name,action=nil)
    def register(name,action=nil,&bl)
    if action.nil? && block_given?
    puts "Before Action.new"
    action=Action.new(&bl)
    #~ action=Action.new
    puts "After Action.new"
    end
    puts action.inspect
    action.name=name
    @actions[name]=action
    action
    end
    end

    actions=Actions.new
    actions.register('exit') {puts "yes"}
    ----------------------------------------------------------------------

    This program now outputs the following:

    fery@domesticus:~/work/tudomany/implementation$ ./gui_test.rb
    Before Action.new
    After Action.new
    #<Proc:0x40276854@./gui_test.rb:32>
    ../gui_test.rb:25:in `register': undefined method `name=' for
    #<Proc:0x40276854@./gui_test.rb:32> (NoMethodError)
    from ./gui_test.rb:32
    fery@domesticus:~/work/tudomany/implementation$


    So, instead of Action, action is a Proc! :-O

    Note, if I remove the &bl from the Actions#register(), then this code do
    not show this behavior, although, there is not so much sense using a
    Proc-derived class without a proc... :-((

    What is the problem?

    Thanks:
    Ferenc

    PS: The previous ruby version was also 1.8.0 (I do not remember the
    exact date). :(
    Ferenc Engard, Oct 5, 2003
    #1
    1. Advertising

  2. Hi,

    In message "Big problem with debian ruby 1.8.0-1"
    on 03/10/06, Ferenc Engard <> writes:

    |I have just upgraded ruby on my debian unstable to ruby 1.8.0-1
    |(2003-10-05), and my program has crashed. Here is the stripped down
    |version of my code:

    A bug.

    --- eval.c 5 Oct 2003 14:07:07 -0000 1.549
    +++ eval.c 6 Oct 2003 00:33:39 -0000
    @@ -6930,3 +6930,3 @@ proc_alloc(klass, proc)

    - if (!proc && ruby_block->block_obj) {
    + if (!proc && ruby_block->block_obj && CLASS_OF(ruby_block->block_obj) == klass) {
    return ruby_block->block_obj;
    Yukihiro Matsumoto, Oct 6, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shaguf
    Replies:
    0
    Views:
    343
    Shaguf
    Dec 24, 2008
  2. Shaguf
    Replies:
    0
    Views:
    443
    Shaguf
    Dec 26, 2008
  3. Luke Kenneth Casson Leighton
    Replies:
    0
    Views:
    467
    Luke Kenneth Casson Leighton
    Dec 31, 2008
  4. Shaguf
    Replies:
    0
    Views:
    229
    Shaguf
    Dec 26, 2008
  5. Shaguf
    Replies:
    0
    Views:
    211
    Shaguf
    Dec 24, 2008
Loading...

Share This Page