Strange type error


#1

Any idea what’s going on in the following?

$ gem install chronic

$ cat test.rb
require ‘rubygems’
require ‘chronic’
puts Chronic.parse(‘3pm’)

$ mono ir.exe test.rb
/var/lib/gems/1.8/gems/chronic-0.2.3/lib/chronic/repeaters/repeater_time.rb:68:in
next': can't convert IronRuby::Builtins::RubyObject into Float (TypeError) from /var/lib/gems/1.8/gems/chronic-0.2.3/lib/chronic/repeaters/repeater_time.rb:67:innext’
from :0:in catch' from mscorlib:0:inCallSite.Target’
from Microsoft.Scripting.Core:0:in
invoke_object__this___CallSite_RubyScope_object_Proc_SymbolId' from /var/lib/gems/1.8/gems/chronic-0.2.3/lib/chronic/repeaters/repeater_time.rb:107:inthis’
from /var/lib/gems/1.8/gems/chronic-0.2.3/lib/chronic/handlers.rb:348:in
find_within' from mscorlib:0:inCallSite.Target’
from Microsoft.Scripting.Core:0:in
invoke_object__this___CallSite_RubyScope_object_SymbolId' from /var/lib/gems/1.8/gems/chronic-0.2.3/lib/chronic/handlers.rb:326:inget_anchor’
from /var/lib/gems/1.8/gems/chronic-0.2.3/lib/chronic/handlers.rb:219:in
handle_r' from /var/lib/gems/1.8/gems/chronic-0.2.3/lib/chronic/handlers.rb:16707566:intokens_to_span’
from :0:in __send__' from mscorlib:0:inCallSite.Target’
from /var/lib/gems/1.8/gems/chronic-0.2.3/lib/chronic/handlers.rb:50:in
tokens_to_span' from :0:ineach’
from mscorlib:0:in CallSite.Target' from /var/lib/gems/1.8/gems/chronic-0.2.3/lib/chronic/chronic.rb:84:inparse’
from test.rb:3
from mscorlib:0:in `CallSite.Target’


#2

I have seen that error message. The fix was the one-line change in
Protocols.cs in
http://github.com/shri/ironruby/commit/09b25e8c573464dc5868ab2521bd631a013527c7.
You can apply that change by hand (its not in the main ironruby repo
yet) and see if that fixes the problem. The error message is somewhat
generic, and it may or may not be the same issue.


#3

2009/5/13 Shri B. removed_email_address@domain.invalid:

I have seen that error message. The fix was the one-line change in Protocols.cs in http://github.com/shri/ironruby/commit/09b25e8c573464dc5868ab2521bd631a013527c7. You can apply that change by hand (its not in the main ironruby repo yet) and see if that fixes the problem. The error message is somewhat generic, and it may or may not be the same issue.

It didn’t fix the problem. Probably a different issue.


#4

http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=1211

IronRuby’s Time implementation doesn’t allow this, while MRI does.

n = Time.now
class RespondToF
def to_f
5.0
end
end
n + RespondToF.new

Chronic does something like this in repeaters/repeater_time.rb:76

~js