Issue #16912 has been reported by pocke (Masataka Kuwabara).

----------------------------------------
Bug #16912: Fiber#raise has a mismatch between implementation and documentation
https://bugs.ruby-lang.org/issues/16912

* Author: pocke (Masataka Kuwabara)
* Status: Open
* Priority: Normal
* ruby -v: ruby 2.8.0dev (2020-05-24T14:47:24Z master c6c023317c) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
Fiber#raise has a mismatch between implementation and documentation for "created" fiber.


RDoc:


> Raises an exception in the fiber at the point at which the last Fiber.yield was called, or at the start if neither resume nor raise were called before.
> 
https://docs.ruby-lang.org/en/2.7.0/Fiber.html#method-i-raise


If my understanding is correct, it says "Fiber#raise raises an exception at the beginning of the fiber if neither resume nor raise were called before.".

But actually it raises a FiberError. I've confirmed the behavior with both of master and v2.7.0.

```bash
$ ruby -ve 'Fiber.new{}.raise' 
ruby 2.8.0dev (2020-05-24T14:47:24Z master c6c023317c) [x86_64-linux]
-e:1:in `raise': cannot raise exception on unborn fiber (FiberError)
	from -e:1:in `<main>'
```


This error has been enabled since https://github.com/ruby/ruby/commit/9ee79b658123a2a4af65c80484d1f91ce73354e2.
And the implemented behavior is tested by 
https://github.com/ruby/ruby/blob/d1251159e98d0cdb99bab953c8d520409e3255ed/test/ruby/test_fiber.rb#L113-L116.
So I guess the documentation is wrong.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>