Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

DateTime arithmetic: Stack level too deep

#4204

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

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

State: resolved
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Greg Campbell
    Greg Campbell

    This is reproducible on my machine. I believe it should be fixed by the patch in #3972 [PATCH] DateTime#to_date returns self when Date#to_date is defined at first.

    April 13th, 2010 @ 07:43 AM

  2. Greg Campbell
  3. Ryan Bigg
    Ryan Bigg
    • State changed from new to resolved

    June 12th, 2010 @ 02:53 AM