rubymotion-community / motion-support

Commonly useful extensions to the standard library for RubyMotion
MIT License
132 stars 28 forks source link

can't convert MotionSupport::Duration into an exact number #20

Closed gvalmon closed 10 years ago

gvalmon commented 10 years ago

Strange issue, not sure if it's related with RubyMotion or MotionSupport.

When I write in motion console, it works fine:

(main)> Time.now + 1.month
=> 2014-04-05 17:56:07 +0400

But when I write the same in compiled method:

def test
   Time.now + 1.month
end

It raises exception:

app_delegate.rb:156:in `test': can't convert MotionSupport::Duration into an exact number (TypeError)

It works fine if i write Time.now + 1.month.to_i

This issue started from latest RubyMotion (2.23/2.24).

Do you know something about it?

Thanks.

tkadauke commented 10 years ago

That sure looks weird. I don't have the current version of RubyMotion installed, so I can't reproduce the issue. Maybe someone else can?

markrickert commented 10 years ago

I can reproduce this in RM 2.24.

Steps:

  1. Clone the motion-support project
  2. typical bundle update, etc. nonesense
  3. rake
  4. in the repl: (main)> Time.now + 1.month => 2014-04-05 11:03:53 -0400
  5. Open the app_delegate.rb file and replace with the code below
  6. rake
  7. in the console:
2014-03-05 11:04:34.587 MotionSupport[78149:80b] app_delegate.rb:7:in `test': can't convert MotionSupport::Duration into an exact number (TypeError)
    from app_delegate.rb:3:in `application:didFinishLaunchingWithOptions:'
2014-03-05 11:04:34.599 MotionSupport[78149:80b] *** Terminating app due to uncaught exception 'TypeError', reason: 'app_delegate.rb:7:in `test': can't convert MotionSupport::Duration into an exact number (TypeError)
    from app_delegate.rb:3:in `application:didFinishLaunchingWithOptions:''
class AppDelegate
  def application(application, didFinishLaunchingWithOptions:launchOptions)
    test
    true
  end
  def test
     Time.now + 1.month
  end
end
Dan2552 commented 10 years ago

Same problem here

tkadauke commented 10 years ago

To me, this looks like it's a RubyMotion issue ... at least part of it. An expression that works in the REPL should also work in a method (given there are no locals involved, as is the case here). Maybe someone in the RubyMotion team wants to comment? @Watson1978?

Watson1978 commented 10 years ago

Hi, guys. Indeed, this is definitely RubyMotion bug. You could track the status in http://hipbyte.myjetbrains.com/youtrack/issue/RM-475, and you could close this.

Thanks

tkadauke commented 10 years ago

Thanks @Watson1978! :-)

kapso commented 10 years ago

Has this been fixed? I am still getting it

$ motion --version
2.31