https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112018-09-13T15:49:06ZRuby Issue Tracking SystemRuby master - Feature #15113: Show warnings on unused blocks with Enumerable#all? any? one? none?https://bugs.ruby-lang.org/issues/15113?journal_id=740242018-09-13T15:49:06Zshevegen (Robert A. Heiler)shevegen@gmail.com
<ul></ul><p>I think nobu committed it already (if it is the same one)</p>
<p><a href="https://git.ruby-lang.org/ruby.git/commit/?id=384fda18b885872aacf225ac6ad7805fb101e497" class="external">https://git.ruby-lang.org/ruby.git/commit/?id=384fda18b885872aacf225ac6ad7805fb101e497</a></p>
<p>I guess it is a useful change; reminds me a bit of the did-you-mean gem, in spirit at<br>
least (both sort of look at possible errors made by humans; and I guess in most or all<br>
cases, where there is no block for these methods, the human user may indeed just have<br>
forgotten it).</p> Ruby master - Feature #15113: Show warnings on unused blocks with Enumerable#all? any? one? none?https://bugs.ruby-lang.org/issues/15113?journal_id=743992018-10-10T17:29:10Zfursich (Onishi Koji)fursich0@gmail.com
<ul></ul><p>Thank you for letting me know robert-san<br>
Yes, looks like this has been quickly merged by nobu-san. (thanksfully enough!)</p>
<p>To your point on human errors, yes, that's actually my intent, so your positive feedback is really encouraging.</p>
<p>This is just an off-topic, side note, but it would have been nicer if such warnings were given with ANY methods when they accidentally receive unused blocks, but that turned out to require quite an unrealistic thorough rework on how blocks are handled internally in ruby (I happened to have an opportunity to have great advises from matz and Endo san on that agenda)</p>
<p>This example is shown by Endo-san, that illustrates fundamental difficulty to detect if/how given blocks are used.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">def</span> <span class="nf">foo</span>
<span class="no">Proc</span><span class="p">.</span><span class="nf">new</span>
<span class="k">end</span>
<span class="n">foo</span> <span class="p">{</span> <span class="nb">puts</span> <span class="s1">'this is a valid block, no warnings are needed.'</span> <span class="p">}.</span><span class="nf">call</span>
<span class="c1"># this is a valid block, no warnings are needed.</span>
</code></pre>
<p>So back to the topic here, I started with these frequently used core methods (which have trapped myself once before).<br>
Hope that saves other developers' days at some point :)</p>
<p>(btw I'm wondering how to close this ticket.. maybe asking somebody in ruby core team might make sense?)</p> Ruby master - Feature #15113: Show warnings on unused blocks with Enumerable#all? any? one? none?https://bugs.ruby-lang.org/issues/15113?journal_id=744212018-10-12T08:37:41Zduerst (Martin Dürst)duerst@it.aoyama.ac.jp
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Closed at proposer's request.</p>