Strange warning-message

Discussion in 'Ruby' started by Sebastian Ruhs, Jul 23, 2004.

  1. Hi!

    I wonder why ruby throws two warning messages when the follwing script
    is executed:
    Code (Text):

    #!/usr/bin/ruby -w

    require 'date'

    aktDate=Date.today
    lastRun=aktDate

    lastRun.upto(aktDate) do |tDate|
    puts "#{tDate.day}.#{tDate.month}.#{tDate.year}"
    end
    [code]

    Output:
    dodger@satan:~/source/ruby$ ./dateTest.rb
    (eval):4: warning: instance variable @__10761__ not initialized
    (eval):4: warning: instance variable @__10337__ not initialized
    23.7.2004

    Someone any idea?

    TIA,
    SR

    PS: System: Debian GNU/Linux Sid with Ruby 1.8.2pre1
     
    Sebastian Ruhs, Jul 23, 2004
    #1
    1. Advertisements

  2. Sebastian Ruhs

    H.Yamamoto Guest

    Hello.

    This warning comes from Date#to_s, and the code below warns with same reason.

    class Foo
    def foo
    if @val; end # evaluate uninitialized instance variable
    end
    end

    Foo.new.foo

    I don't know if this is intended warning. (1.8.1 doesn't warn)
     
    H.Yamamoto, Jul 23, 2004
    #2
    1. Advertisements

  3. Sebastian Ruhs

    H.Yamamoto Guest

    Hello.
    I'm not sure I can call it a bug... I think this warning message is just telling us
    "You are using uninitialized variable. Do you know what you are doing? Isn't there
    any spelling miss?" like "if (fp = fopen(path, "r"))" in C-language.

    But anyway, this was fixed by matz yesterday. It will be included in ruby-1.8.2pre2.
     
    H.Yamamoto, Jul 24, 2004
    #3
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.