Strange warning-message

S

Sebastian Ruhs

Hi!

I wonder why ruby throws two warning messages when the follwing script
is executed:
Code:
#!/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
 
H

H.Yamamoto

Hello.

(eval):4: warning: instance variable @__10761__ not initialized
(eval):4: warning: instance variable @__10337__ not initialized
23.7.2004

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

H.Yamamoto

Hello.
Ok, if this warning comes from the use of an uninitialized instance
variable then there is a bug in the Date-class, right?

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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top