https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112017-12-04T10:38:20ZRuby Issue Tracking SystemRuby master - Feature #14153: [PATCH] resurrection of # -*- warn_past_scope: true -*-https://redmine.ruby-lang.org/issues/14153?journal_id=681762017-12-04T10:38:20Zshyouhei (Shyouhei Urabe)shyouhei@ruby-lang.org
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/10661">Bug #10661</a>: The "possible reference to past scope" warning is quite frustrating and is forcing me to change my variable names from what I want</i> added</li></ul> Ruby master - Feature #14153: [PATCH] resurrection of # -*- warn_past_scope: true -*-https://redmine.ruby-lang.org/issues/14153?journal_id=681812017-12-04T10:49:39Zshyouhei (Shyouhei Urabe)shyouhei@ruby-lang.org
<ul></ul><p>This patch works like this:</p>
<pre><code>% ./ruby --disable-gems -w -ve '[1, 2, 3].sample.tap { |rand| puts "Random value: #{rand}" }; puts "Another random value: #{rand}"'
ruby 2.5.0dev (2017-12-04 warn_past_scope 61011) [x86_64-darwin15]
Random value: 3
Another random value: 0.25989520023218615
%
%
% ./ruby --disable-gems -w -ve '# warn_past_scope: true' -e '[1, 2, 3].sample.tap { |rand| puts "Random value: #{rand}" }; puts "Another random value: #{rand}"'
ruby 2.5.0dev (2017-12-04 warn_past_scope 61011) [x86_64-darwin15]
-e:2: warning: possible reference to past scope - rand
Random value: 2
Another random value: 0.5832209137869108
%
</code></pre> Ruby master - Feature #14153: [PATCH] resurrection of # -*- warn_past_scope: true -*-https://redmine.ruby-lang.org/issues/14153?journal_id=681882017-12-04T16:44:11Zshevegen (Robert A. Heiler)shevegen@gmail.com
<ul></ul><p>I have no pro or con opinion so I will not comment on the suggestion.</p>
<p>I have one question though, apologies for a bit of side tracking:</p>
<ul>
<li>Can this be combined with other comment options such as "# frozen_string_literal: true"</li>
</ul>
<p>?</p>
<p>Perhaps it may not apply as your example is only commandline but<br>
I wanted to ask just in case anyone may want to combine more<br>
than one option, for whatever reason, into the .rb file at hand.</p> Ruby master - Feature #14153: [PATCH] resurrection of # -*- warn_past_scope: true -*-https://redmine.ruby-lang.org/issues/14153?journal_id=681912017-12-04T18:04:16Zmarcandre (Marc-Andre Lafortune)marcandre-ruby-core@marc-andre.ca
<ul></ul><p>Seems to me to be more appropriate as a Rubocop cop.</p> Ruby master - Feature #14153: [PATCH] resurrection of # -*- warn_past_scope: true -*-https://redmine.ruby-lang.org/issues/14153?journal_id=681932017-12-05T00:52:39Zshyouhei (Shyouhei Urabe)shyouhei@ruby-lang.org
<ul></ul><p><a class="user active user-mention" href="https://redmine.ruby-lang.org/users/3414">@shevegen (Robert A. Heiler)</a> Yes. You can write multiple magic comments</p>
<ul>
<li>
<p>at once, like this:</p>
<pre><code> # -*- coding: utf-8; frozen_string_literal: true; warn_indent: true; warn_past_scope: true -*-
</code></pre>
</li>
<li>
<p>or, line by line like this:</p>
<pre><code> # coding: utf-8
# frozen_string_literal: true
# warn_indent: true
# warn_past_scope: true
</code></pre>
</li>
</ul> Ruby master - Feature #14153: [PATCH] resurrection of # -*- warn_past_scope: true -*-https://redmine.ruby-lang.org/issues/14153?journal_id=689702017-12-26T08:29:52Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul></ul><p>At least, I don't like the name <code>warn_past_code</code>. It's not intuitive.<br>
And it may be better to be handled by Rubocop as Marc-Andre said.</p>
<p>Matz.</p> Ruby master - Feature #14153: [PATCH] resurrection of # -*- warn_past_scope: true -*-https://redmine.ruby-lang.org/issues/14153?journal_id=689782017-12-26T08:53:18Zdsferreira (Daniel Ferreira)
<ul></ul><p>Are we relying on rubocop as ruby’s official linter?</p>
<p>This question comes inline with my recent previous comment around core functionalities that I believe should be better managed as part of ruby API.<br>
Debugger, Coverage, Unit tests, Benchmarks, Performance tools and yes Linter.<br>
Missing Documentation here.<br>
Maybe something else?</p>