-
Notifications
You must be signed in to change notification settings - Fork 35
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
FiberError
with Enumerator
on Ruby < 3.0
#55
Comments
Huh, weird, I've seen that error before, but the other way round, when calling Ruby's So given this pattern: def example
return to_enum(:example) unless block_given?
yield 1
yield 2
yield 3
nil
end
example {|i| p i} # prints "1\n2\n3\n"
e = example #=> #<Enumerator: main:example>
e.next #=> 1
e.next #=> 2 You'd expect to be able to write the following with Magnus: fn example(rb_self: Value) -> Result<Value, Error> {
if !block::block_given() {
return Ok(*rb_self.enumeratorize("example", ()));
}
let _: Value = block::yield_value(1)?;
let _: Value = block::yield_value(2)?;
let _: Value = block::yield_value(3)?;
Ok(*QNIL)
} However that gets you Aside: Now I try this, the error is only occurring on Ruby <= 3.0. I'm pretty sure 3.0 was the latest release when I first encountered this. I've only tested this particular case on M1 (originally) and M2 (now) Macs. I tracked this down to the call to fn example(rb_self: Value) -> block::Yield<impl Iterator<Item = i64>> {
if block::block_given() {
block::Yield::Iter((1..=3).into_iter())
} else {
block::Yield::Enumerator(rb_self.enumeratorize("example", ()))
}
} and have it work correctly with either a block or returning an Enumerator. I don't think I can safely do the same thing for |
I adapted an existing test to use a heterogeneous array and can't reproduce this on CI main...heterogeneous-enumerator-test |
I’m consistently getting a
FiberError
back frommagnus::Enumerator::next
on Ruby 2.6 and Ruby 2.7:See this
serde-magnus
CI run for an example.Strange details:
[1234, true, "Hello, world!"]
, not[123, 456, 789]
.I suspect ruby/ruby#4606 fixed this in Ruby 3.0.The timing isn’t right. 🤷♂️Not sure if there’s anything to be done about this. Wanted to flag just in case.
The text was updated successfully, but these errors were encountered: