Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby Enumerator#next broken iOS #423

Open
jtara opened this issue Nov 15, 2014 · 2 comments
Open

Ruby Enumerator#next broken iOS #423

jtara opened this issue Nov 15, 2014 · 2 comments
Assignees

Comments

@jtara
Copy link

jtara commented Nov 15, 2014

Using Rhodes 5.0.2 (from RMS 5.0.2).

Enumerator#next terminates app with no logging.

    test_enum = [1,2,3].to_enum
    app_info "test_enum = #{test_enum.inspect}"
    current_test = test_enum.next   # Ka-pow! Rhodes bombs!
    app_info "current_test = #{current_test.inspect}"  # we do not get here

(Yes, I know I need an exception handler to detect the end when looping through. But no loop above. current_test should be set to 1.)

Works in Ruby 1.9.2-p290 (same version as Rhodes) on OSX desktop irb.

This is on iOS simulator. Need to test on device to see if it bombs there as well, and see if anything in system log.

@jtara jtara changed the title Ruby Enumerator#next possibly broken iOS Ruby Enumerator#next broken iOS Nov 15, 2014
@jtara
Copy link
Author

jtara commented Nov 16, 2014

I think it may be related to this:

https://www.ruby-forum.com/topic/196086

That's a discussion about jRuby. But it mentions an implementation detail of #next:

  1. On the first call to #next, a fiber or generator is spun up to
    start the call to each, similar to this:
    f = Fiber.new { collection.each {|i| Fiber.yield i} }
  2. For each element next returns, the fiber/generator is invoked to
    produce the next result
    def next
    f.resume
    end
  3. When the enumeration completes (or at any time) you can rewind and
    start from the beginning.

I'd guess that Rhodes doesn't implement Fibers.

If that's the case, Enumerator#next needs to be documented as not implemented.

I wonder what else in Ruby is depending on fibers?

@vmusulainen
Copy link
Contributor

It's reproduced on rhodes v.5.5.0.51 & 6.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants