Issue #15974 has been updated by chrisseaton (Chris Seaton).


> Question: shouldn't this be an error rather than a warning?

No, because it's possible to have a reference from the finaliser to the object when the finaliser is created, but then to later clear that reference and the finaliser to work properly. The specs cover this.

However this PR was reverted due to some bugs (I wrote it in a couple of hours at a hackathon and it was merged then and there, so not surprising it wasn't really fully baked yet!) I hope to get it back in at some point.

----------------------------------------
Feature #15974: Warn in verbose mode on defining a finalizer that captures the object
https://bugs.ruby-lang.org/issues/15974#change-80422

* Author: chrisseaton (Chris Seaton)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
There's a really common mistake people make when using `define_finalizer` - they capture the object in the finalizer.

https://www.mikeperham.com/2010/02/24/the-trouble-with-ruby-finalizers/

This PR warns about that, when in verbose mode (it's too slow to do always.)

https://github.com/ruby/ruby/pull/2264



-- 
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>