This project is archived and is in readonly mode.

#4204 ✓resolved
Pieter Bos

DateTime arithmetic: Stack level too deep

Reported by Pieter Bos | March 17th, 2010 @ 01:11 PM

Do the following in a Rails 3.0.0.beta app (on ruby 1.8.7 at least)

script/rails console
DateTime.now - 1.day

Result:

SystemStackError: stack level too deep
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta/lib/active_support/core_ext/date_time/calculations.rb:52:in `advance'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta/lib/active_support/core_ext/date_time/calculations.rb:52:in `advance'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta/lib/active_support/duration.rb:90:in `sum'
from (irb):4:in `inject'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta/lib/active_support/duration.rb:85:in `each'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta/lib/active_support/duration.rb:85:in `inject'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta/lib/active_support/duration.rb:85:in `sum'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta/lib/active_support/duration.rb:61:in `since'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta/lib/active_support/core_ext/date/calculations.rb:67:in `plus_with_duration'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta/lib/active_support/core_ext/date/calculations.rb:77:in `-'
from (irb):4

Workaround: use to_i, then convert back to datetime. It's annoying though. Verified both on windows (mingw32 build) and mac OS

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages